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

David M. Lloyd david.lloyd at redhat.com
Wed May 20 15:34:12 EDT 2009


On 05/20/2009 01:54 PM, Gregg Wonderly wrote:
> Any thread may be interrupted at any point in its execution path.  The 
> fact that InterruptedException is a checked exception is the predominant 
> issue from my perspective.  It can be thrown from code which does not 
> declare it to be thrown as a checked exception.

Um, no, at least no more than any other checked exception.

All interruption does is set a flag.  If the interrupted thread is blocked 
in an interruptible operation, then the thread is unblocked and it will 
generally either throw InterruptedException or re-set the interrupted flag 
and do Something Else (which might include throwing some other exception).

The point of this issue is that Class.newInstance() can throw undeclared 
checked exceptions, so you shouldn't use it, period.  Use 
Class.getConstructor().newInstance() instead.  Other than that, you 
generally won't get InterruptedException unless you're calling a method 
that declares it.

- DML



More information about the Concurrency-interest mailing list