[concurrency-interest] Thread interruption protocol: InterruptedException is a "checked" exception, correct?
Thomas.Hawtin at Sun.COM
Thu May 21 08:43:02 EDT 2009
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. InterruptedException
> should be a RuntimeException because of this... But, this will likely
> never be something that can be changed for backward compatibility.
Inserting a superclass like that should not usually be a significant
campatibility problem. In the specific case of Exception ->
RuntimeException there are a couple problems that spring to mind.
* Where methods (such as Atomic*FieldUpdate.newInstance) are specified
to throw a RuntimeException in some cases, which may result in a catch
RuntimeException without a catching all checked Exceptions.
* AccessController.doPrivileged has freaky a specification and, in
Sun's JRE, implementations - four overloads, but only two
implementations. The PrivilegedExceptionAction versions let unchecked
exceptions through (to be similar to the PrivilegedAction versions) but
wrap checked exceptions.
OTOH, interruprs are a PITA. Making them disappear is probably not going
to encourage people to make an effort to handle them sensibly.
More information about the Concurrency-interest