首页 > 编程语言 > 详细

线程状态

时间:2019-06-14 19:47:08      阅读:100      评论:0      收藏:0      [点我收藏+]

NEW(A thread that has not yet started is in this state.)
尚未启动的线程处于此状态。 Thread t = new Thread ();

RUNNABLE (A thread executing in the Java virtual machine is in this state.)
在Java虚拟机中执行的线程处于此状态。 new Thread().start();

BLOCKED (A thread that is blocked waiting for a monitor lock is in this state.)
被阻塞等待监视器锁定的线程处于此状态。 synchronized(this) -> while (flag)->obj.wait();

WAITING (A thread that is waiting indefinitely for another thread to perform a particular action is in this state.)
正在等待另一个线程执行特定动作的线程处于此状态。 Object.wait Thread.join LockSupport.park

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.)
正在等待另一个线程执行动作达到指定等待时间的线程处于此状态。 Thread.sleep Object.wait(timeout) Thread.join(timeout) LockSupport.parkNanos LockSupport.parkUntil

TERMINATED (A thread that has exited is in this state.)
已退出的线程处于此状态。

线程状态

原文:https://www.cnblogs.com/sleepingDogs/p/11024963.html

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