aspose file tools
The moose likes Threads and Synchronization and the fly likes simple Q about thread.interrupt() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "simple Q about thread.interrupt()" Watch "simple Q about thread.interrupt()" New topic
Author

simple Q about thread.interrupt()

Raymond
Greenhorn

Joined: Sep 26, 2004
Posts: 1
Dear all,

I just have one simple Q about thread.interrupt(). I wonder what thread.interrupt() really does in the java program. from the name, I guess it is used when we would like to interupt the thread excution. But when I read some meterial in the internet, it is said it wakes the thread up(Wake up a sleeping thread or blocked thread).

Can anyone please enlighten me on this question.

Thanks a lot.

Raymond
[ September 26, 2004: Message edited by: Raymond ]
Warren Dew
blacksmith
Ranch Hand

Joined: Mar 04, 2004
Posts: 1328
The material you have read is correct.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
The interrupt() method will cause a wait() or sleep() method to stop blocking and throw InterruptedException. There may be a few other such methods, but unfortunately I/O is not included; you cannot unblock a read() on a stream by using interrupt().

If the Thread on which interrupt() is called is not in one of the System methods that respond to it, then user code can see that the interrupt has happened, by using isInterrupted() or interrupted(). It is then up to the user code to do decide what to do.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: simple Q about thread.interrupt()
 
Similar Threads
join() and completely stopping a thread
Thread.interrupt kills database connection
String replace
Killing of Threads
best way to kill ?