Java中线程的状态类型
线程的状态类型
源码作者的原注释关于线程内部类
State描述了线程的六个状态
- A thread state. A thread can be in one of the following states:
①、NEW
- 尚未启动的线程处于此状态
- 源码中的注释
A thread that has not yet started is in this state.
②、RUNNABLE
- 在Java虚拟机中执行的线程处于这种状态
- 源码中的注释
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.
④、WATING
- 无限期等待另一个线程执行特定操作的线程处于此状态
- 源码中的注释
A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
⑤、TIMED_WATING
-
一个线程等待另一个线程执行操作,在指定的等待时间内处于此状态
-
源码中的注释
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.
小结
- 可以用一个枚举类来说明线程的这几个状态
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

