February 2014
Beginner
1248 pages
62h 25m
English
It’s considered good practice to let the executing thread handle InterruptedExceptions. Normally, you’d do this by declaring that method run throws the exception, rather than catching the exception. However, recall from Chapter 11 that when you override a method, the throws may contain only the same exception types or a subset of the exception types declared in the original method’s throws clause. Runnable method run does not have a throws clause in its original declaration, so we cannot provide one in line 21. To ensure that the executing thread receives the InterruptedException, line 32 first obtains a reference to the currently executing Thread by calling static method currentThread, then uses that ...
Read now
Unlock full access