Hi,
I realized that what I said wasn't totally clear.
If your thread is interrupted and you ignore it nothing happens. This means that no one else can
force the thread to shut down by interrupting it. Interruption is a mechanism that allows threads to behave themselves but a thread is not required to behave, so it doesn't make much sense to interrupt threads who's behavour when interrupted is unknown. You can check to see if your thread has been interrupted by calling
From the sun
java api
doc
Tests whether the current thread has been interrupted. The interrupted status of the thread is cleared by this method. In other words, if this method were to be called twice in succession, the second call would return false (unless the current thread were interrupted again, after the first call had cleared its interrupted status and before the second call had examined it).
If you call interrupted and then do something, like log it, you can call interrupt() to restore (not return as I mistyped in the previous post) its interrupt status.
One last way a thread can stop prematurely is due to an uncaught exception. If you extend ThreadGroup and override the uncaughtException method this method will be called when your thread dies, so here you can do stuff like log the problem or even start a new thread.
So I think that the ways a thread can stop are
1. reach the end of the run method
2. jvm explodes and kills the thread
3. gets interrupted and kills itself
5. gets exploded by a runtime exception
If anyone knows any other ways please tell me
Niki