title: ForkJoinPool resets thread interrupted state
body: <p>I just noticed the following phenomena when cancelling a Future returned by <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinPool.html" rel="nofollow">ForkJoinPool</a>. Given the following example code:</p>
  
  <pre><code>ForkJoinPool pool = new ForkJoinPool();
  Future&lt;?&gt; fut = pool.submit(new Callable&lt;Void&gt;() {
  
    @Override
    public Void call() throws Exception {
      while (true) {
        if (Thread.currentThread().isInterrupted()) { // &lt;-- never true
          System.out.println("interrupted");
          throw new InterruptedException();
        }
      }
    }
  });
  
  Thread.sleep(1000);
  System.out.println("cancel");
  fut.cancel(true);
  </code></pre>
  
  <p>The program never prints <code>interrupted</code>. The docs of <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinTask.html#cancel%28boolean%29" rel="nofollow">ForkJoinTask#cancel(boolean)</a> say:</p>
  
  <blockquote>
    <p>mayInterruptIfRunning - this value has no effect in the default implementation because interrupts are not used to control cancellation.</p>
  </blockquote>
  
  <p>If ForkJoinTasks ignore interrupts, how else are you supposed to check for cancellation inside Callables submitted to a ForkJoinPool?   </p>