rogerb at rogerbinns.com
Wed Jun 16 23:32:08 CEST 2004
Peter Hansen wrote:
> I didn't think things worked quite that way in Java. For
> example, I thought InterruptedException was seen by a thread
> only if it had actually been asleep at the time it was sent.
> I also didn't know it would actually terminate certain
> blocking calls, such as in socket stuff.
As is the Java way, they have different types of interrupted
exceptions and sockets etc would need to be InterruptibleChannels.
They also use checked exceptions which makes life a lot harder.
More on Java best practises for thread interruption:
I would just settle for a nice clean mechanism whereby you can
call Thread.interrupt() and have an InterruptException in that
thread (which ultimately terminates the thread if it isn't
Some threads won't be interruptible because they are deep in
extension libraries. Perhaps that can be returned to the
caller of Thread.interrupt().
More information about the Python-list