I want to force method run for specified time.
public Response run(Request req){
//method runImpl must run during specified interval of time(for example for 10 secs)
Response res = runImpl(req);
return response;
}
What is the best way to do this?Thanks!
Try to use this:
poolExecutor = new ScheduledThreadPoolExecutor(1);
poolExecutor.scheduleAtFixedRate(
new YourRunable(), startFrom/*10*/, startEvery/*5*/, TimeUnit.SECONDS);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With