I am using ScheduledExecutorService, and after I call it's cancel method on scheduleFuture, I can't schedule a Runnable on it. Calling scheduleAtFixedRate(runnable, INITIAL_DELAY, INTERVAL, TimeUnit.SECONDS)
after cancel()
, nothing happens. Is there any way to restart the ScheduledExecutorService
after cancel()
method is called?
Please review notes on Future and its implementation FutureTask .
The effect of calling cancel() method is that:
subsequent calls to isDone() will always return true. Subsequent
calls to isCancelled() will always return true if this method
returned true.
Once the computation has completed, the computation cannot be restarted or cancelled.
Meaning, if a call to isDone()
returns true
, whether or not you made a call to cancel()
, you can't use same instance of your service.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.