title: Java thread interruption won't work for me (in groovy)
body: <p>Feeling stupid somehow as I'm now trying to get a simple interrupt for a thread working in groovy for some hours already.</p>
  
  <p>Somehow following code won't set the 'interrupted' flag in the thread 'name'. Causing the loop to run 'til its end.</p>
  
  <p>Found tons of other questions where usually the check for <code>Thread.currentThread().isInterrupted()</code> was missing. But this is not the case here:</p>
  
  <pre><code>def t = Thread.start('name') {
      try {
          for (int i = 0; i &lt; 10 &amp;&amp; !Thread.currentThread().isInterrupted(); ++i) {
              println "$i"
              sleep 1000
          }
      } catch (InterruptedException e) {
          println "Catched exception"
          Thread.currentThread().interrupt();
      }
  }
  println "Interrupting thread in 1..."
  sleep 1000
  println "Interrupting thread..."
  t.interrupt()
  sleep 2000
  </code></pre>
  
  <p>I get following output</p>
  
  <pre><code>Interrupting thread in 1...
  0
  Interrupting thread...
  1
  2
  3
  4
  5
  6
  7
  8
  9
  </code></pre>
  
  <p>Wonder what I miss here / am doing wrong?
  Tried also using <code>ExecutorService</code> and calling <code>cancel(true)</code> on the returned Future. Didn't work either.</p>