public static enum Thread.State extends Enum<Thread.State>
NEW
RUNNABLE
BLOCKED
WAITING
TIMED_WAITING
TERMINATED
一个线程可以在给定时间点处于一个状态。 这些状态是不反映任何操作系统线程状态的虚拟机状态。
Thread.getState()
Enum Constant and Description |
---|
BLOCKED
一个线程的线程状态阻塞等待监视器锁定。
|
NEW
线程尚未启动的线程状态。
|
RUNNABLE
可运行线程的线程状态。
|
TERMINATED
终止线程的线程状态。
|
TIMED_WAITING
具有指定等待时间的等待线程的线程状态。
|
WAITING
等待线程的线程状态
|
Modifier and Type | Method and Description |
---|---|
static Thread.State |
valueOf(String name)
以指定的名称返回此类型的枚举常量。
|
static Thread.State[] |
values()
按照它们声明的顺序返回一个包含此枚举类型常量的数组。
|
public static final Thread.State NEW
public static final Thread.State RUNNABLE
public static final Thread.State BLOCKED
Object.wait
后重新输入同步的块/方法。
public static final Thread.State WAITING
Object.wait
没有超时 Thread.join
没有超时 LockSupport.park
等待状态的线程正在等待另一个线程执行特定的动作。 例如,已经在对象上调用Object.wait()线程正在等待另一个线程调用该对象上Object.notify() Object.notifyAll()或。 调用Thread.join()的线程正在等待指定的线程终止。
public static final Thread.State TIMED_WAITING
public static final Thread.State TERMINATED
public static Thread.State[] values()
for (Thread.State c : Thread.State.values())
System.out.println(c);
public static Thread.State valueOf(String name)
name
- 要返回的枚举常量的名称。
IllegalArgumentException
- 如果此枚举类型没有指定名称的常量
NullPointerException
- 如果参数为空
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.