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:
Gui gui = new Gui() // class that implements runnable
Thread guiThread = new Thread(gui, "gui thread");
guiThread.start()
...
...
guiThread.interrupt();
gui.cancel();
Currently my cancel code looks like this, however it isn't correctly setting the interrupt status of this thread.
public void cancel()
{
Thread.currentThread().interrupt();
// other clean up code here.
}
Any advice on if/how i could get this working?
Thanks.
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.