In our application when a user clicks on commandlink, a pop up is generated. This click will pass an id to process.
My managed bean is viewscoped and I am creating a thread to do some tasks.
In a scenario where a user clicks on the link a pop up is generated and the thread has started executing jobs, say the user closes the pop up and tries to click the link providing a different id this time. My problem is the previous thread which was started is not being destroyed. I can still get the latest id details as a response but the previous thread still executes jobs.
I would like to know if there is a way to terminate the previous instance thread on a new request. I know I can achieve this using sessionscoped but popups are being opened in the same session.
just as a quick solution possible for your use case:
calling:
boolean cancel(boolean mayInterruptIfRunning)
In your case the call should use:
mayInterruptIfRunning=true
The only quesion left is: Where to keep the Future reference? :)
We can discuss that if you want as well :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With