首页 > 编程语言 > 详细

Java线程的6种状态

时间:2020-03-08 23:08:44      阅读:71      评论:0      收藏:0      [点我收藏+]

一: 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:
 

Java线程的6种状态

原文:https://www.cnblogs.com/majestyking/p/12445612.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!