Java Thread Sleep and Interrupted Exception Java Thread Sleep and Interrupted Exception multithreading multithreading

Java Thread Sleep and Interrupted Exception


An InterruptedException is thrown when the thread is blocked/waiting and it is interrupted by another thread (by means of Thread.interrupt). Think of it as a request for immediate termination, that do not suffer the drawbacks of Thread.stop().

This way, even if you instruct a thread to sleep for several years, you are able to interrupt that thread.

The recommended practice is aborting whatever you are processing when a InterruptedException is thrown.


  1. Because a Thread cant complete its normal execution if you Interrupt it, and you need to catch that in order to be prepared to do something.
  2. Because a thread waiting is different from an interrupted thread, a thread waiting can be resumed, but an interrupted thread is already finish execution.


When you ask a thread to sleep, the expected behavior for that thread is to sleep for that much time. So if the sleep is interrupted, it will throw InterruptedException to indicate that it couldn't complete the task. And you might want to take care of what should be done if it is Interrupted.