Thread.isInterrupted doesn't work, Thread.interrupted does Thread.isInterrupted doesn't work, Thread.interrupted does multithreading multithreading

Thread.isInterrupted doesn't work, Thread.interrupted does


This looks like a known issue with multi-processor machines, mainly in 64-bit OS and java versions from 1.5 - 7.0

A DESCRIPTION OF THE PROBLEM :While running two simultaneous threads, the first thread interrupts the second one using Thread.interrupt().The second thread tests if it has been interrupted calling the Thread.isInterrupted() method which always returns false.

This occurs on a multiprocessor PC running a 64-Bit OS (Vista and Linux).On Vista 64-Bit, this occurs when using a 64-bit JVM (all versions from 1.5 to 1.7), but does not occur when using a 32-bit JVM.On Linux 64-bit, this occurs when using a 64-bit JVM (all versions from 1.5 to 1.7) or when using a 32-bit JVM (all versions from 1.5 to 1.7).

The solution is to install the version with the fix, which is 1.6.0_16-b02 or later.


ripper234, i just ran this on my machine and it always stops no matter what value i use for the prints and which interrupts to use. I am using jdk1.6.0_16. looking at the javadoc, maybe it has something to do with the fact that interrupted() clears the (interrupted) state after each call and isInterrupted() does not. the fact that it works sometimes for jerome, always for me, and never(?) for you could indicated a difference in the jdks we are using OR the speed of our machines. if it has anything to do with the clearing of the state, that might explain the variability.