title: Interrupting a thread from inside a runnable class? (java)
body: <p>I am trying to set up a method inside a class that implements the runnable interface that will set the interrupt status of that class. The reason i want to be able to do it from inside the class is there is some other clean up stuff that i need to take care of as well, and i would like to be able to do it all by calling one method instead of calling, for example:</p>
  
  <pre><code>Gui gui = new Gui() // class that implements runnable
  
  Thread guiThread = new Thread(gui, "gui thread");
  
  guiThread.start()
  
  ...
  
  ...
  
  guiThread.interrupt();
  
  gui.cancel();
  </code></pre>
  
  <p>Currently my cancel code looks like this, however it isn't correctly setting the interrupt status of this thread.</p>
  
  <pre><code>public void cancel()
  
  {
  
    Thread.currentThread().interrupt();
  
    // other clean up code here.
  
  }
  </code></pre>
  
  <p>Any advice on if/how i could get this working?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: I when i tried to get the cancel working, i commented out the guiThread.interrupt(), so that i wasn't just setting the status the reseting the status.</p>