explain the life cycle of thread?

Answer Posted / god&

There are five states New,Runnable,Running,Blocked,Dead

New state – After the creations of Thread instance the
thread is in this state but before the start() method
invocation. At this point, the thread is considered not
alive.

Runnable (Ready-to-run) state – A thread start its life
from Runnable state. A thread first enters runnable state
after the invoking of start() method but a thread can
return to this state after either running, waiting,
sleeping or coming back from blocked state also. On this
state a thread is waiting for a turn on the processor.

Running state – A thread is in running state that means the
thread is currently executing. There are several ways to
enter in Runnable state but there is only one way to enter
in Running state: the scheduler select a thread from
runnable pool.

Dead state – A thread can be considered dead when its run()
method completes. If any thread comes on this state that
means it cannot ever run again.

Blocked - A thread can enter in this state because of
waiting the resources that are hold by another thread.

Is This Answer Correct ?    34 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why there are some null interface in java? What does it mean?

649


Can you explain the private protected field modifier?

576


What are benefits of java?

562


What is starvation?

688


Explain about interthread communication and how it takes place in java?

550






What is finalize()? Is finalize() similar to a destructor?

546


Where are the card layouts used?

616


Is final static java?

553


What is Enum in Java?

686


What are loops in java? What are three types of loops?

555


What is a boolean output?

532


Is jdk required on each machine to run a java program?

759


Is arraylist dynamic in java?

527


Can we overload final method in java?

557


What is java instanceof operator?

570