首页   快速返回

java线程状态
文章分类 java
发布时间 2018-09-27 修改时间 2018-09-27
java线程总共有6中状态 NEW RUNNABLE BLOCKED WAITING TIMED_WAITING TERMINATED
在 java.lang.Thread.State里定义

NEW 未调用start方法启动

RUNNABLE 准备就绪 等待调度执行

BLOCKED  阻塞等待 monitor lock  synchronized

WAITING  无限期等待 调用以下方法进入该状态  Object.wait Thread.join LockSupport.park


TIMED_WAITING  超时等待 调用以下方法进入该状态
               Thread.sleep
               Object.wait(long)
               Thread.join(long)
               LockSupport.parkNanos
               LockSupport.parkUntil
               
TERMINATED   线程运行结束 

Thread 
State getState() 获取线程状态 


jstack 可以获取 线程堆栈信息  

 java.lang.Thread.State: WAITING (parking)
 java.lang.Thread.State: RUNNABLE
 java.lang.Thread.State: TIMED_WAITING (sleeping)
 java.lang.Thread.State: TIMED_WAITING (parking)
 java.lang.Thread.State: TIMED_WAITING (on object monitor)
 java.lang.Thread.State: WAITING (on object monitor)
 java.lang.Thread.State: BLOCKED (on object monitor)

上一篇     下一篇
Lock和synchronized的区别

java并发机制的底层实现原理

域名查询命令

互联网新老词汇对照表

NoClassDefFoundError和ClassNotFoundException异常的区别

进程线程与协程的区别