国王陛下万万岁

导航

 

一: Java的线程一共有6种状态,这是来自java官方源代码里面定义的,是最权威的。

 

  1.       NEW
  2.       RUNNABLE
  3.       BLOCKED
  4.       WAITING
  5.       TIMED_WAITING
  6.       TERMINATED

二: 如何查看源码: 输入以下代码,在IntelliJ Idea中按快捷键ctrl+B

Thread.State

 

三: A thread state.

  • {@link #NEW}
    A thread that has not yet started is in this state.
  • {@link #RUNNABLE}
    A thread executing in the Java virtual machine is in this state.
  • {@link #BLOCKED}
    A thread that is blocked waiting for a monitor lock is in this state.
  • {@link #WAITING}
    A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
  • {@link #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.
  • {@link #TERMINATED}
    A thread that has exited is in this state.

  A thread can be in one of the following states:
 

posted on 2020-03-08 22:39  国王陛下万万岁  阅读(170)  评论(0编辑  收藏  举报