Reputation: 409
I am trying to programmatically stop a running Job in PlayFramework. When a Job is run, I save the 'Promise' object that it returns when it's started. This object has a 'cancel' method that SHOULD cancel a scheduled job OR stop an existing job, however it doesn't seem to do anything.
What other way is there to stop a running Job?
Upvotes: 1
Views: 877
Reputation: 29999
I think you need to implement well-ordered cancellation yourself. cancel
won't just end the thread's execution as this may cause undesired results. The solution is similar too how Thread.stop()
is deprecated and Thread.interrupt()
should be used instead.
Check if the job got cancelled at occasion. If you are running heavy calculation in a loop, check if it still should continue running at the beginning. You can even return partial results this way.
Upvotes: 1