Sangel Kapoor wrote:
Given the fact that Thread.sleep() thows Interrupted Exceptions . It means that , this thread checks the state continuously for being interrupted or not, which essentially means
that this thread though sleeping from the Runnable point of view is not actually sleeping but still being scheduled for checking the state .
Given this argument, you can also argue that threads are never blocked waiting for I/O either -- meaning the "thread checks the state continuously for being [I/O exception] or not"...
Of course, the thread is not polling continuously. That would make the sleep() method call very inefficient.... Basically, the thread is asleep (not running), and the act of interruption makes it runnable again (wakes it up). Later when the thread runs (wakes up), it will check why it is up, and if it is due to interruption, it will throw the exception.
Henry