My question is related to all of these methods (including Thread.sleep(...) ) that throw InterruptedException .
I found a Sun manual that says
InterruptedException is an exception when sleep throws when another thread interrupts the current thread while the sleep asset is.
Does this mean that the interrupt will be ignored if sleep not active during the interrupt?
Suppose I have two threads: threadOne and threadTwo . threadOne creates and starts threadTwo . threadTwo executes runnable, whose start method looks something like this:
public void run() { : : try { Thread.sleep(10 * 1000); } catch (InterruptedException e) { return; } : : :
After creating the thread, threadOne aborts threadTwo . Suppose threadTwo is in the middle of two sleep calls during an interrupt (when the sleep method was not used), then the second sleep method will throw an InterrupteException as soon as it is called?
If not, will this interrupt be ignored forever?
How to be sure that threadTwo will always know about the interrupt (it doesnβt matter if one of its sleep methods is active)?
source share