Thread Life Cyclefor Bca
Thread Life Cyclefor Bca
Thread Life Cyclefor Bca
Running State:--
If the thread is in execution then it is said to be in running state.
The thread can finish its work and end normally.
The thread can also be forced to give up the control when one of the
following conditions arise
1. A thread can be suspended by suspend( ) method. A suspended thread can be
revived by using the resume() method.
2. A thread can be made to sleep for a particular time by using the
sleep(milliseconds) method.
The sleeping method re-enters runnable state when the time elapses.
3. A thread can be made to wait until a particular event occur using the wait()
method, which can be run again using the notify( ) method.
Blocked State:--
A thread is said to be in blocked state if it prevented from entering into the
runnable state and so the running state.
The thread enters the blocked state when it is suspended, made to sleep or
wait.
A blocked thread can enter into runnable state at any time and can resume
execution.
Dead State:--
The running thread ends its life when it has completed executing the run()
method which is called natural dead.
The thread can also be killed at any stage by using the stop( ) method.