Possible Duplicate:
Handling InterruptedException in Java
I wonder how InterruptedException should be properly handled. What actions should be performed in catch block? Are there any circumstances when the exception should be delegated to the higher level class?
The point of InterruptedException is to allow a blocking method to cancel early, when requested. The one thing you shouldn’t do is nothing; don’t just swallow the exception.
If you can’t throw the exception from your method, calling
Thread.currentThread().interrupt()is usually a good bet.Check out Brian Goetz’s article, http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html, for a good discussion on this topic. Edit: looks like somebody suggested this article already – in any case, it’s a good read.