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 ]
Joined: Mar 04, 2004
The material you have read is correct.
Joined: Oct 30, 2001
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