Although SUN deprecated some thread methods, a user should be familiar with what they were and why they were deprecated.
Pausing a thread
Often the ability to suspend a thread without a specific time limit is useful.
Suppose, for example, you are building an applet with an animation thread, you
might want to provide the user with the option to pause the animation until the
user wanted to resume.
You do not want to throw the animation away, you want to de-activate it. For
this type of thread control you can use
t1.suspend();
This method does not halt the execution permanently. The thread is suspended
indefinately until you activate the thread using
t1.resume();
A thread will automatically suspend() and then resume() when it's first blocked
at a synchronized point and then later unblocked (when it is that threads turn
to "run").
Stopping a thread
We can stop a thread with
t1.stop(); // stops the thread by throwing a ThreadDeath
error.
This does not destroy the thread, but it halts execution. When a thread is
stopped, the state of the thread object is set so that it is not restartable.
Execution cannot be restarted by using t1.start(). The
start() method won't return an exception condition, but the
run()
method also won't be called. The isAlive()method also won't return
true.
In the examples shown, we did not need to explicitly stop the threads. We
simply let them finish. A thread runs until the run() method returns or until
the stop() method of its Thread object is called. More complex threaded
examples will require control over each thread; the stop() method can be used
therein.
If needed, you can test to see if your thread is "alive". A thread is
alive if it has been started and has not been stopped.
t1.isAlive(); // returns true if t1 is alive
Why JavaSoft is Deprecating Thread.stop,
Thread.suspend and Thread.resume and also look at the deprecated methods in the thread API
What happens when you try to restart a thread? The answer is that it
actually depends on when you restart it. When the stop() method is
called on a thread, it actually takes time for the thread to stop. Hence, what
happens when the start() method is called depends on a race condition.