-
assigned issue to
- edited description
- marked as blocker
- changed milestone to 0.2.0.5 - UI
BotTask.stop() doesn't stop current execution
TimerTasks cannot be interrupted while they are running. task.cancel(), timer.cancel() , timer.purge() only prevents a new execution.
In our case we have some time-expensive run() tasks, and we want to be able to force-stop them.
After some research, this is the best solution I've found for us :
- : each task should have an AtomicBoolean interrupted ; field. BotTask.stop() will set interrupted to true.
Then, in the logic body of run() we constantly monitor that variable and if we find it to be true we simply return;
We could also do something similar and use ScheduledExecutorService. As explained here , we should also perform constant check in the body of run(), exactly like the solution I propose. And it will be also costly migrating all BotTasks to ScheduledExecutorService. This is why I propose going with the first solution .
Comments (5)
-
reporter -
reporter - edited description
-
ok. interrerupted is similar to the session variable I have introduced
-
reporter - changed status to resolved
-
reporter - changed milestone to 0.3.0 - UI
- Log in to comment