States of a Thread

 States of a thread

New: When thread is created, it will go to the new state.

Runnable: When we call the start() method, then thread will go to the Runnable state, If multiple threads are created and for all the threads if start() method is invoked, then all the threads will go to the Runnable state.

Running: Under Running states, there are 3 sub-states. and under Running state at a time only one thread will be present. It depends on the thread scheduler which thread it schedule.

i) Sleep: when sleep method is called, then the thread will go to the Sleep state.

ii)Blocked: When the requested resources are not available, then the thread will go to the Blocked state.

iii)Wait: When wait method is invoked, then the thread will go to the wait state, and again when we call notify() or notifyAll(), then again it will go back to the runnable state 

Dead: When the thread life is completed, then it will go to Dead state.





Comments

Popular posts from this blog

Eclipse debugging

Advantages and Disadvantages of Monolithic Architecture