Translate

Thursday, June 9, 2016

Life cycle of a thread

Thread lifecycle-


There are 5 states in a thread life cycle.
1. New
2.Runnable
3.Running
4.Blocked
5.Terminated


1.New

The thread is in new state if you create the instance of Thread class but before invocation of start() method.

2.Runnable

The thread is in runnable state if you invoke the thread but thread scheduler has not selected to it to be the running thread.

3.Running

The thread is in running state if thread scheduler selected it.

4.Blocked

The thread is in blocked state if thread is still alive, but not currently not eligible to run because lack  of some resources.

5.Terminated

The thread is in blocked state if thread completes it's execution.



No comments:

Post a Comment