[concurrency-interest] Thread interruption protocol: InterruptedException is a "checked" exception, correct?

David Holmes davidcholmes at aapt.net.au
Thu May 21 18:08:36 EDT 2009


Gregg Wonderly writes:
> I've tried to stay away from InterruptedException and
> Thread.interrupt().  I guess I am under the incorrect assumption that a
call to
> Thread.interrupt() can cause an InterruptedException to be raised in a
thread executing
> inside of a method without a "throws InterruptedException" clause?

Thread.interrupt does not trigger an asynchronous exception the way
Thread.stop does. Specific blocking methods in the core APIs are specified
to raise/throw InterruptedException if they detect thread interruption and
as it is a checked exception you are generally aware (modulo VM bugs and
Class.newInstance quirkiness) where this can arise. Other methods that
utilize blocking are then encouraged to throw InterruptedException if they
wish to be "cancellation points". The I/O API's take a different approach to
responding to interrupts, but are still basically cancellation points -
where cancelling implies "close this channel".

David Holmes




More information about the Concurrency-interest mailing list