JavaTM 2 Platform
Standard Ed. 6

java.lang
枚举 Thread.State

java.lang.Object
  继承者 java.lang.Enum<Thread.State>
      继承者 java.lang.Thread.State
所有已实现的接口:
Serializable, Comparable<Thread.State>
正在封闭类:
Thread

public static enum Thread.State
extends Enum<Thread.State>

线程状态。线程可以处于下列状态之一:

在给定时间点上,一个线程只能处于一种状态。这些状态是虚拟机状态,它们并没有反映所有操作系统线程状态。

从以下版本开始:
1.5
另请参见:
Thread.getState()

枚举常量摘要
BLOCKED
          受阻塞并且正在等待监视器锁的某一线程的线程状态。
NEW
          至今尚未启动的线程的状态。
RUNNABLE
          可运行线程的线程状态。
TERMINATED
          已终止线程的线程状态。
TIMED_WAITING
          具有指定等待时间的某一等待线程的线程状态。
WAITING
          某一等待线程的线程状态。
 
方法摘要
static Thread.State valueOf(String name)
          返回带有指定名称的该类型的枚举常量。
static Thread.State[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
从类 java.lang.Enum 继承的方法
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
从类 java.lang.Object 继承的方法
getClass, notify, notifyAll, wait, wait, wait
 

枚举常量详细信息

NEW

public static final Thread.State NEW
至今尚未启动的线程的状态。


RUNNABLE

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


BLOCKED

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


WAITING

public static final Thread.State WAITING
某一等待线程的线程状态。某一线程因为调用下列方法之一而处于等待状态:

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


TIMED_WAITING

public static final Thread.State TIMED_WAITING
具有指定等待时间的某一等待线程的线程状态。某一线程因为调用以下带有指定正等待时间的方法之一而处于定时等待状态:


TERMINATED

public static final Thread.State TERMINATED
已终止线程的线程状态。线程已经结束执行。

方法详细信息

values

public static final Thread.State[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for(Thread.State c : Thread.State.values())
        System.out.println(c);

返回:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Thread.State valueOf(String name)
返回带有指定名称的该类型的枚举常量。 字符串必须与用于声明该类型的枚举常量的 标识符完全匹配。(不允许有多余 的空格。)

参数:
指定要返回的枚举常量的名称。 -
返回:
返回带有指定名称的枚举常量
抛出:
如果该枚举类型没有带有指定名称的常量, - 则抛出 IllegalArgumentException

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策