Thread States

The thread state specifies the current status of the thread. Some times, the thread automatically switches from one state to another state automatically; at some other times, you can switch it’s state by using the methods offered by “Thread” class.
The following diagram describes the different states of a thread.
multi threading
1. Ready: This is the initial state. The thread object is created.
2. Running: The thread is currently being executed.
3. Sleeping: The thread is temporarily paused. .NET framework offers automatic switching between “Running” and “Sleeping” states, when other threads are executed.
4. Dead: The thread was closed.

“Thread” class methods:

1. thobj.Start()
This method starts-up the thread execution.

2. Thread.Sleep(mille sec)
This method puts the thread under “Sleeping” state, up to a certain no. of mille seconds. When the given no. of mille seconds are completed, automatically the thread execution will be continued.

3. thobj.Suspend()
This is similar to “Sleep()” method, but here, no time limit will be given. That means whenever the “Suspend()” method is called, the thread will be put under “Suspended” state, until the “Resume()” method is called.

4. thobj.Resume()
This is to continue the thread execution that is under “Suspended” state. This method won’t work if the thread is not under “Suspended” state.

5. thobj.Abort()
This is close the thread execution completely, at any time. Once, if the “Abort()” method is called, the thread can’t be started or resumed. This is the end of every thread life cycle.