Handling InterruptedException in Java

What is the difference between the following ways of handling InterruptedException? What is the best way to do it?

try{
 //...
} catch(InterruptedException e) { 
   Thread.currentThread().interrupt(); 
}

OR

try{
 //...
} catch(InterruptedException e) {
   throw new RuntimeException(e);
}

EDIT: I’d like to also know in which scenarios are these two used.

7 Answers
7

Leave a Comment