# 多线程——线程的几种状态 (Java API版)

## 1. NEW

NEW: 新建状态，指已经创建了线程对象，但是该线程尚未启动，即还没有调用start()方法。根据Java api，定义如下：

## 2. RUNNABLE

RUNNABLE: 按照字面翻译是“可运行的”, 但是根据Java api中的定义：

A thread in the runnable state is executing in the jvm but it may be waiting for other resources from the operating system such as processor

## 3. BLOCKED

BLOCKED：阻塞状态，根据Java api中的定义：

A thread in the blocked state is waiting for a monitor lock to enter a synchronized block/method or reenter a synchronized block/method after calling Object.wait()

## 4. WAITING

WAITING：等待状态，根据Java api，该状态的诱发原因如下：

A thread is in the waiting state due to calling one of the following methods:
Object.wait with no timeout
LockSupport.park

A thread in the waiting state is waiting for another thread to perform a particular action. For example, a thread that has 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 called Thread.join() is waiting for a specified thread to terminate

## 5. TIMED_WAITING

TIME_WAITING：有限时间的等待状态，根据Java api的定义，该状态的诱发原因如下：

Thread state for a waiting thread with a specified waiting time. A thread is in the timed waiting state due to calling one of the following methods with a specified positive waiting time:
Object.wait with timeout
LockSupport.parkNanos
LockSupport.parkUntil

sleep(long millis)、wait(long timeout)、join(long millis)、parkNanos(long nanos)和 parkUntil(long deadline)的情况。

## 6. TERMINATED

TERMINATED：终止状态/死亡状态，指线程执行完毕，该线程的run()方法已执行完毕。根据Java api，定义如下：