12-02-2009, 10:43 AM
Join Date: Mar 2008
Location: Austin, TX
Post Thanks: 0
Thanked 34 Times in 33 Posts
I think the correct steps are:
1. Set a variable that is queried by the thread run() loop (like isDone). The run() loop should always exit when this value is set.
2. call thread.interrupt() to break the thread from any current sleep()
3. call thread.join() to wait for the thread to die.
You can also use thread.isActive() to check and see if the thread is really dead.
Now, having said all of that, I never re-use a thread. I kill the old one, set the reference to null (so that it can be garbage collected), and start a new thread.