Explain the Java thread state diagram and discuss the method

Explain the Java thread state diagram and discuss the methods that can change the state.

Solution

The Java thread state diagram :-

The life cycle of a thread consists of several states. At any time the thread is falls into any one of the states.

* The thread that was just created is in the Born state.

* The thread remains in this state until the threads start method is called which causes the thread to enter the Ready state.

* The highest priority ready thread enter the Running state when the system assigns a processor to the thread i.e. the thread begins executing.

* When a running thread calls wait the thread enters into a waiting state for the particular object on which wait was called. Every thread in the waiting state for a given object becomes ready on a call to notify all by another thread associated with that object.

* When a sleep method is called in a running thread, that thread enters into the suspended state. A sleeping thread becomes ready after the designated sleep time expires. A sleeping thread cannot use a processor even if one is available.

* A thread enters the dead state when its run( ) method complete (or) terminates for anyreason. A dead thread is eventually be disposed of by the system.

* One common way for a running thread to enter the blocked state is when the thread issues an input or output request. In this case a blocked thread becomes ready when the input or output waits for completes. A blocked thread can’t use a processor even if one is available.

Explain the Java thread state diagram and discuss the methods that can change the state.SolutionThe Java thread state diagram :- The life cycle of a thread cons

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site