The thread state is identified in Java by an internal enumeration of the thread.
NEW---->runnable---->blocked---->waiting---->timed_waiting---->terminated
1. Creation status (Thread.State.NEW)
If you just create a thread and do not start it (start), the thread state is created.
For example: Thread thread1 = new Thread ();
The thread in the creation State has not yet obtained the resources it deserves, so this is an empty thread. The system will assign resources to a thread only after it has been started.
2. Operational status (Thread.State.RUNNABLE)
Start a thread by calling T.start () to put the thread into a running (Thread.State.RUNNABLE) state. The thread in that State enters the ready queue, and when the thread gets the CPU the time slice starts to run.
3. Blocking State ( thread.state. BLOCKED )
The thread state of one of the threads that is blocked and is waiting for a monitor lock. A thread in a blocked state is waiting for a monitor lock to enter a synchronized block/method, or to enter the synchronized block/method again after calling Object.wait.
4. Wait State ( Thread.State.WAITING ,timed_waiting)
The thread state of a waiting thread. A thread is waiting because it calls one of the following methods:
Object.wait with no time-out value
Thread.Join with no time-out value
Locksupport.park
A thread that is waiting waits for another thread to perform a specific operation. For example, a thread that has already called object.wait () on an object is waiting for another thread to call Object.notify () or Object.notifyall () on that object. A thread that has already called thread.join () is waiting for the specified thread to terminate.
Timed_waiting the thread state of a waiting thread with a specified wait time. A thread is in a timed wait state because it calls one of the following methods with the specified positive wait time:
Thread.Sleep
Object.wait with time-out value
Thread.Join with time-out value
Locksupport.parknanos
Locksupport.parkuntil
5, End state (thread.state. TERMINATED)
This article is from the "program Ape's Cultivation" blog, please be sure to keep this source http://zhoum1118.blog.51cto.com/10054110/1660101
Java Thread State Analysis