Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!