Duplicate :
|
There is a race condition between sleep() and interrupt() (and possibly start()): if the timing is right, thread can enter TIMED_WAITING state and isInterrupted() will return true at the same time, which effectively renders assumption that any interrupts received before sleep() timeout will result in InterruptedException wrong. interrupt() happens here but the thread can react only here V V ccccccccccccccccc1gggggggssssssssssssssssssssssssssssssssssssscc calculations gap sleep