Interrupt is to indicate a thread that it should stop doing what it is currently doing and exit.
Sleep honors interrupt and since it is an exception condition, it indicates it by throwing an exception i.e. InterruptedException.
Whenever an interrupted exception occurs, you must always set the interrupted status back to the thread (via Thread's interrupt() method), stop what you were doing and return. So, the answer to your initial question that you should put sleep in a loop is "No". You should not eat InterruptedException unless you are pretty sure of it.
Thread.sleep(millis) does not guarantee that it will sleep for the provided duration. No assumption can be made that if you specify it to sleep for 2seconds, its gonna sleep for 2 seconds. If there are any interrupts, then sleep can be interrupted, hence it throws an InterruptedException.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Why does the method Thread.sleep() declare that it might throw an exception?