explain the life cycle of thread?

Answer Posted / dinesh kumar

1 Newborn State

2 Runnable State

3 Running State

4 Blocked State

5 Dead State
1 Newborn State

When we create a thread it will be in Newborn State.

The thread is just created still its not running.

We can move it to running mode by invoking the start() method and it can be killed by using stop() method.
2 Runnable State

It means that thread is now ready for running and its waiting to give control.

We can move control to another thread by yield() method.

3 Running State

It means thread is in its execution mode becaause the control of cpu is given to that particular thread.

It can be move in three different situation from running mode.
These all are different methods which can be apply on running thread and how the state is changing and how we can come in our original previous state using different methods are shown in above figure.

4 Blocked State

A thread is called in Blocked State when it is not allowed to entering in Runnable State or Running State.

It happens when thread is in waiting mode, suspended or in sleeping mode.

5 Dead State

When a thread is completed executing its run() method the life cycle of that particular thread is end.

We can kill thread by invoking stop() method for that particular thread and send it to be in Dead State.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is bytecode verifier?

508


What is incompatible types in java?

545


What is serialization in java?

570


Describe different states of a thread.

582


What is string builder?

474






What are the benefits of immutable objects?

544


What is public static?

501


Which class is the superclass for all the classes?

538


What steps are taken when the OS shifts from one-thread execution to another?

908


What is a "pure virtual" member function?

601


Explain some best practices you would apply while using collection in java?

576


Explain, java is compatible with all servers but not all browsers?

617


How will you calculate the depth of a binary tree if the tree contains 15 nodes?

602


What is the difference between Error, defect,fault, failure and mistake?

666


What is backdrop?

601