百木园-与人分享,
就是让自己快乐。

12-Java中线程的状态类型

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.

小结

  • 可以用一个枚举类来说明线程的这几个状态

来源:https://www.cnblogs.com/OnlyOnYourself-lzw/p/16557635.html
本站部分图文来源于网络,如有侵权请联系删除。

未经允许不得转载:百木园 » 12-Java中线程的状态类型

相关推荐

  • 暂无文章