首页 > 代码库 > java线程状态

java线程状态

从java.lang.Thread.State可以看到java线程有以下状态:

  • NEW
        A thread that has not yet started is in this state.

  • RUNNABLE
        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.

  • WAITING
        A thread that is waiting indefinitely for another thread to     perform a particular action is in this state.

  • 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.

  • TERMINATED
        A thread that has exited is in this state.

These states are virtual machine states which do not reflect any operating system thread states.

操作系统定义的线程状态有:

新建,就绪,阻塞,运行,死亡。

java线程状态BLOCKED,WAITING,TIMED——WAITING对应操作系统线程的阻塞状态。

线程状态的转换

技术分享

java线程状态