Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should generally NOT ignore the exception. Take a look at the following paper:</p> <blockquote> <p><strong>Don't swallow interrupts</strong></p> <p>Sometimes throwing InterruptedException is not an option, such as when a task defined by Runnable calls an interruptible method. In this case, you can't rethrow InterruptedException, but you also do not want to do nothing. When a blocking method detects interruption and throws InterruptedException, it clears the interrupted status. If you catch InterruptedException but cannot rethrow it, you should preserve evidence that the interruption occurred so that code higher up on the call stack can learn of the interruption and respond to it if it wants to. This task is accomplished by calling interrupt() to "reinterrupt" the current thread, as shown in Listing 3. At the very least, whenever you catch InterruptedException and don't rethrow it, reinterrupt the current thread before returning.</p> <pre><code>public class TaskRunner implements Runnable { private BlockingQueue&lt;Task&gt; queue; public TaskRunner(BlockingQueue&lt;Task&gt; queue) { this.queue = queue; } public void run() { try { while (true) { Task task = queue.take(10, TimeUnit.SECONDS); task.execute(); } } catch (InterruptedException e) { // Restore the interrupted status Thread.currentThread().interrupt(); } } } </code></pre> <ul> <li>From <a href="http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html?ca=drs-#2.1" rel="noreferrer">Don't swallow interrupts</a></li> </ul> </blockquote> <hr> <p>See the entire paper here: </p> <p><a href="http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html?ca=drs-" rel="noreferrer">http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html?ca=drs-</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload