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

Interrupt Handling  RSS feed

 
Java Kt
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have read it on http://download.oracle.com/javase/tutorial/essential/concurrency/interrupt.html that
if a thread goes a long time without invoking a method that throws InterruptedException, then it must periodically invoke Thread.interrupted,
which returns true if an interrupt has been received.


If i am rightly understood the statement it means do we have to hadle interrup check in our code ,if thread goes a long time without invoking
a method that throws InterruptedException? Is it correct?

considering the below example if the interruption comes during sleep it will print the message
but if the interruption comes once the thread comes out of sleep it wont go inside catch block for InterruptedException
} correct?



 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!