Friday, August 01, 2008

Handling java.lang.InterruptedException

What do most Java developers do when they are faced with handling an InterruptedException? This should look very familiar;

try{
// Do something
} catch (InterruptedException ignored){
log.debug("Exception", ignored);
}

We've seen plenty of code that does this, it makes us wonder whether InterruptedException is just useless and simply clutters the code. The question is, "Is this the correct way of handling InterruptedException". The answer is, "No, it isn't always the best way of handling this exception".

Dealing with InterruptedException is an excellent article that points out how this exception needs to be handled in different scenarios. It is a "must read" for any Java developer. When an InterruptedException is thrown, the interrupted status of the thread is cleared. Hence, at least we should set the interrupted status again using the Thread.currentThread().interrupt() method so that somebody else could handle it, if necessary.

1 comments:

Anonymous said...

порновидео с малолетками онлайн http://free-3x.com/ девки малолетки онлайн free-3x.com/ порно онлайн школьники [url=http://free-3x.com/]free-3x.com[/url]