ScheduledExecutorService worker threads retain interrupted status after FutureTask.cancel(true)?

The answers are: It is not left in an interrupted state. The implementation does but you are not looking in the right spot From the Oracle library code: /* * Ensure that unless pool is stopping, this thread * does not have its interrupt set. This requires a * double-check of state in case the interrupt was * cleared concurrently with a shutdownNow -- if so, * the interrupt is re-enabled.

*/ if (runState = STOP) thread.interrupt(); As you can see, the interrupt state is cleared from the worker thread so long as the executor is not shutting down.

True that! I saw that piece of code the first time and misread it as only applying when pool was shutting down. I still have no idea how I am getting the interrupted exception; perhaps I'm canceling and scheduling the task at the same time without realizing it.

– Justin Nov 10 '10 at 22:43 If the user cancels while the task is executing, how do you handle the InterruptedException which will be thrown at the next blocked call? – Tim Bender Nov 10 '10 at 23:38 I just catch it, log it and return (its a restartable batch process) – Justin Nov 11 '10 at 0:05.

If they're using a UI component, your issue may be due to synchronization problems with the event dispatch thread.

2 It is not a swing application. As it says in the question: the task (a FutureTask) is canceled by some arbitrary thread via ScheduledFuture. Cancel(true).

– Justin Nov 10 '10 at 21:02.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions