java线程的几种状态

jdk api中的描述:

NEW
至今尚未启动的线程处于这种状态。

RUNNABLE
正在 Java 虚拟机中执行的线程处于这种状态。可运行线程的线程状态。处于可运行状态的某一线程正在 Java 虚拟机中运行,但它可能正在等待操作系统中的其他资源,比如处理器。

BLOCKED
受阻塞并等待某个监视器锁的线程处于这种状态。受阻塞并且正在等待监视器锁的某一线程的线程状态。处于受阻塞状态的某一线程正在等待监视器锁,以便进入一个同步的块/方法,或者在调用 Object.wait 之后再次进入同步的块/方法。 

WAITING
无限期地等待另一个线程来执行某一特定操作的线程处于这种状态。

某一等待线程的线程状态。某一线程因为调用下列方法之一而处于等待状态:

处于等待状态的线程正等待另一个线程,以执行特定操作。 例如,已经在某一对象上调用了 Object.wait() 的线程正等待另一个线程,以便在该对象上调用 Object.notify()Object.notifyAll()。已经调用了 Thread.join() 的线程正在等待指定线程终止。 

TIMED_WAITING
等待另一个线程来执行取决于指定等待时间的操作的线程处于这种状态。

TERMINATED
已退出的线程处于这种状态。

 

英文描述其实更清楚:

NEW
A thread that has not yet started is in this state.

RUNNABLE
A thread executing in the Java virtual machine is in this state.

BLOCKED
A thread that is blocked waiting for a monitor lock is in this state.

WAITING
A thread that is waiting indefinitely for another thread to perform a particular action is in this state.

TIMED_WAITING
A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.

TERMINATED
A thread that has exited is in this state.

posted @ 2012-03-21 23:09  lostyue  阅读(860)  评论(0编辑  收藏  举报