public static enum Thread.State  extends Enum<Thread.State>线程状态。
线程可以处于下列状态之一:
1.NEW 至今尚未启动的线程的状态。
2.RUNNABLE 可运行线程的线程状态。
        处于可运行状态的某一线程正在 Java 虚拟机中运行,但它可能正在等待操作系统中的其他资源,比如处理器。
3.BLOCKED 受阻塞并且正在等待监视器锁的某一线程的线程状态。
        处于受阻塞状态的某一线程正在等待监视器锁,以便进入一个同步的块/方法,或者在调用 Object.wait 之后再次进入同步的块/方法。
4.WAITING 某一等待线程的线程状态。某一线程因为调用下列方法之一而处于等待状态:

  • 不带超时值的 Object.wait
  • 不带超时值的 Thread.join

LockSupport.park
处于等待状态的线程正等待另一个线程,以执行特定操作。
例如,已经在某一对象上调用了 Object.wait() 的线程正等待另一个线程,以便在该对象上调用 Object.notify() 或 Object.notifyAll()。
    已经调用了 Thread.join() 的线程正在等待指定线程终止。
5.TIMED_WAITING具有指定等待时间的某一等待线程的线程状态。某一线程因为调用以下带有指定正等待时间的方法之一而处于定时等待状态:

  • Thread.sleep
  • 带有超时值的 Object.wait
  • 带有超时值的 Thread.join
  • LockSupport.parkNanos
  • LockSupport.parkUntil

6.TERMINATED
已终止线程的线程状态。线程已经结束执行。
注意:在给定时间点上,一个线程只能处于一种状态。这些状态是虚拟机状态,它们并没有反映所有操作系统线程状态。
为了展现线程在运行时的状态及其转换,我画了下面这个图

    /*** A thread state.  A thread can be in one of the following states:* <ul>* <li>{@link #NEW}<br>*     A thread that has not yet started is in this state.*     </li>* <li>{@link #RUNNABLE}<br>*     A thread executing in the Java virtual machine is in this state.*     </li>* <li>{@link #BLOCKED}<br>*     A thread that is blocked waiting for a monitor lock*     is in this state.*     </li>* <li>{@link #WAITING}<br>*     A thread that is waiting indefinitely for another thread to*     perform a particular action is in this state.*     </li>* <li>{@link #TIMED_WAITING}<br>*     A thread that is waiting for another thread to perform an action*     for up to a specified waiting time is in this state.*     </li>* <li>{@link #TERMINATED}<br>*     A thread that has exited is in this state.*     </li>* </ul>** <p>* A thread can be in only one state at a given point in time.* These states are virtual machine states which do not reflect* any operating system thread states.** @since   1.5* @see #getState*/public enum State {/*** Thread state for a thread which has not yet started.*/NEW,/*** Thread state for a runnable thread.  A thread in the runnable* state is executing in the Java virtual machine but it may* be waiting for other resources from the operating system* such as processor.*/RUNNABLE,/*** Thread state for a thread blocked waiting for a monitor lock.* A thread in the blocked state is waiting for a monitor lock* to enter a synchronized block/method or* reenter a synchronized block/method after calling* {@link Object#wait() Object.wait}.*/BLOCKED,/*** Thread state for a waiting thread.* A thread is in the waiting state due to calling one of the* following methods:* <ul>*   <li>{@link Object#wait() Object.wait} with no timeout</li>*   <li>{@link #join() Thread.join} with no timeout</li>*   <li>{@link LockSupport#park() LockSupport.park}</li>* </ul>** <p>A thread in the waiting state is waiting for another thread to* perform a particular action.** For example, a thread that has called <tt>Object.wait()</tt>* on an object is waiting for another thread to call* <tt>Object.notify()</tt> or <tt>Object.notifyAll()</tt> on* that object. A thread that has called <tt>Thread.join()</tt>* is waiting for a specified thread to terminate.*/WAITING,/*** Thread state for a waiting thread with a specified waiting time.* A thread is in the timed waiting state due to calling one of* the following methods with a specified positive waiting time:* <ul>*   <li>{@link #sleep Thread.sleep}</li>*   <li>{@link Object#wait(long) Object.wait} with timeout</li>*   <li>{@link #join(long) Thread.join} with timeout</li>*   <li>{@link LockSupport#parkNanos LockSupport.parkNanos}</li>*   <li>{@link LockSupport#parkUntil LockSupport.parkUntil}</li>* </ul>*/TIMED_WAITING,/*** Thread state for a terminated thread.* The thread has completed execution.*/TERMINATED;}

java.lang.Thread.State

http://www.blogjava.net/cpegtop/articles/377980.html

转载于:https://www.cnblogs.com/softidea/p/3984146.html

Java Thread Status(转)相关推荐

  1. java Thread sleep 和obj.wait,以及sychronized,minor源码

    sleep()方法是Thread类里面的,主要的意义就是让当前线程停止执行,让出cpu给其他的线程,但是不会释放对象锁资源以及监控的状态,当指定的时间到了之后又会自动恢复运行状态. wait()方法是 ...

  2. 深入Java Thread底层源码实现

    深入Java Thread底层实现 介绍 Thread就是程序中一个线程的执行.JVM允许一个应用中多个线程并发执行 每个线程都有优先级.高优先级线程优先于低优先级线程执行 每个线程都可以(不可以)被 ...

  3. How to Analyze Java Thread Dumps--reference

    原文地址:http://architects.dzone.com/articles/how-analyze-java-thread-dumps The Performance Zone is pres ...

  4. Java Thread

    Java Thread 使用Java多线程编程很容易. Java线程总是实现接口java.lang.Runnable, 一般有两种方法: 创建一个类实现接口Runnable, 创造该类的实例作为参数传 ...

  5. Java Thread 和 Park

    引言 从本篇文章开始,将会是一些和 Java 多线程相关的杂谈,本篇文章主要介绍 JVM 对 JavaThread 实现,以及 Thread Park 的实现.更多相关文章和其他文章均收录于贝贝猫的文 ...

  6. Java Thread 实现方式

    关于Thread有一个比较有趣的面试题.当你new 一个Thread的时候,直接调用它的run()方法,run()会执行在哪个线程? 答案是调用run()的线程,因为只有在调用start()之后,Ja ...

  7. (转)性能分析之-- JAVA Thread Dump 分析综述

    原文链接:http://blog.csdn.net/rachel_luo/article/details/8920596 最近在做性能测试,需要对线程堆栈进行分析,在网上收集了一些资料,学习完后,将相 ...

  8. 三个实例演示 Java Thread Dump 日志分析

    jstack Dump 日志文件中的线程状态 dump 文件里,值得关注的线程状态有: 死锁,Deadlock(重点关注) 执行中,Runnable 等待资源,Waiting on condition ...

  9. 各种 Java Thread State 第一分析法则

    用 TDA 工具,看到大量 Java Thread State 的第一反应是: 1,线程状态为"waiting for monitor entry": 意味着它 在等待进入一个临界 ...

最新文章

  1. golang 导出变量、函数 首字母必须大写
  2. 红帽将召开“开放你的世界”在线论坛
  3. DotNetCore Web应用程序中的Cookie管理
  4. 华为产品技术学习笔记之路由原理(一)
  5. win10自动休眠解决方法
  6. unity 录制游戏内视频(1)
  7. oracle 实现自增序列
  8. 活水决策体系五:自我觉察与控制
  9. 不小心删除电脑系统所有字体的解决方法
  10. 行测技巧:十字交叉法解决比值混合问题
  11. 论文阅读——TR-GAN: Topology Ranking GAN with Triplet Loss for Retinal Artery/Vein Classification
  12. 【职场必备知识】毕业留蓉政策与发展前景分析
  13. 十余种漂亮照片边框简单制作技巧
  14. 【GStreamer 】1-扫盲介绍
  15. Re: 从0开始的DMD学习
  16. 浙里办APP对接常见问题
  17. 如何搭建一个拥有个人域名又带点Geek味的独立博客
  18. TIOBE 编程语言排行,各个语言优缺点,以及你适合那种编程语言
  19. MongoDB数据库简介
  20. 软考初级程序员上午单选题(20)

热门文章

  1. hashmap中的hash扰动函数
  2. 线程同步以及yield()、wait()、Notify()、Notifyall()
  3. Myeclipse 安装Aptana3.2 插件
  4. 在main函数前后执行的函数之 C语言
  5. rebuild online意外终止导致ora-8104错误的实验
  6. 他山之石,可以攻玉——来自亚马逊的电商启示录
  7. 100个直接可以拿来用的JavaScript实用功能代码片段
  8. 文档中根元素后面的标记格式必须正确。
  9. 计算机网络第1章(概述)
  10. 数据结构——顺序栈和链式栈的简单实现和解析(C语言版)