This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InterruptedException

 
pramod karnani
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

when InterruptedException is being catch in lock method since wait throws InterruptedException then can I wrap InterruptedException within a subclass of RuntimeException ?

let say subclass is UserInterruptedException that extends RuntimeException


Regards,
Pramod
 
Roel De Nijs
Sheriff
Posts: 10223
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pramod,

I posted a question about how to handle the InterruptedException (more than a month ago) and got no replies at all. The thread can be found here and has a link to a website with an article about "how to handle InterruptedException?", so it's maybe valuable to you

Kind regards,
Roel
 
Alecsandru Cocarla
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not read that article before submitting my assignment, so I just swallowed the exception and continued to wait. However, I don't think I'd have changed my approach. But I had a TimeoutException, which means anyway, after 5 seconds, the thread exits. So swallowing is just a delay, there's no possibility that my thread remains stuck, waiting forever.

This is my "InterruptedException code":

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic