I have this code:
ScheduledExecutorService scheduledExecutor;
.....
ScheduledFuture<?> result = scheduledExecutor.scheduleWithFixedDelay(
new SomethingDoer(),0, measurmentPeriodMillis, TimeUnit.MILLISECONDS);
After some event I should stop action, which Declared in run()
method of the SomethingDoer
, which implements Runnable
.
How can I do this? I can't shutdown executor, I should only revoke my periodic task. Can I use result.get()
for this? And if I can, please tell me how it will work.