Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How should one deal with InterruptedException ?. Any best practices ?  RSS feed

 
Steven Rodeo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been looking at few articles on line on how to deal with InterrruptedException, do you folks suggest any best practices ?.

-SR
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As suggested in Java concurrency in practice,

Never eat the Interrupted exception.

Either propagate it to your caller(re-throw or don't catch) or set the Interrupted status back in the thread using

The above is on the assumption that someone in the calling stack knows how to deal with it. That someone typically will be your thread pool.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!