Explain how to Stop and Block a Thread?

https://www.computersprofessor.com/2016/12/explain-how-to-stop-and-block-thread.html
|
Stopping a
thread:
whenever we
want to stop a thread from running further, we call stop() method.
x.stop( );
|
This statement
causes the thread to move to the dead state. A thread will also move to the
dead state automatically when it reaches the end of the method.
|
The stop( )
method may be used when the premature death of a thread is desired.
Blocking a thread
:
A thread can
also be temporarily suspended or blocked from entering in to the runnable and
subsequently running state by using either of the following thread methods.
.
sleep( )®blocked
for a specified time
suspend ( )®blocked
until further orders.
wait( )®blocked
until certain condition occurs.
These methods
cause the thread to go into the blocked (or not runnable ) state.
|
The thread
will return to the runnable state when the specified time is elapsed in the
case of sleep( ),
|
The resume( )
is involved in the case of suspend( ) and
|
notify( ) is
called case of wait( ).
|