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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…