A thread state. A thread can be in one of the following states:

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

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.

  • NEW

    public static final Thread.State NEW
    Thread state for a thread which has not yet started.
  • RUNNABLE

    public static final Thread.State RUNNABLE
    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.
  • BLOCKED

    public static final Thread.State BLOCKED
    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 Object.wait.
  • WAITING

    public static final Thread.State WAITING
    Thread state for a waiting thread. A thread is in the waiting state due to calling one of the following methods:

    A thread in the waiting state is waiting for another thread to perform a particular action. For example, a thread that has called Object.wait() on an object is waiting for another thread to call Object.notify() or Object.notifyAll() on that object. A thread that has calledThread.join() is waiting for a specified thread to terminate.

  • TERMINATED

    public static final Thread.State TERMINATED
    Thread state for a terminated thread. The thread has completed execution.
  • park

    public static void park()
    Disables the current thread for thread scheduling purposes unless the permit is available.

    If the permit is available then it is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:

    • Some other thread invokes unpark with the current thread as the target; or
    • Some other thread interrupts the current thread; or
    • The call spuriously (that is, for no reason) returns.

    This method does not report which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread upon return.

  • parkNanos

    public static void parkNanos(long nanos)
    Disables the current thread for thread scheduling purposes, for up to the specified waiting time, unless the permit is available.

    If the permit is available then it is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

    • Some other thread invokes unpark with the current thread as the target; or
    • Some other thread interrupts the current thread; or
    • The specified waiting time elapses; or
    • The call spuriously (that is, for no reason) returns.

    This method does not report which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread, or the elapsed time upon return.

    Parameters:
    nanos - the maximum number of nanoseconds to wait
  • parkUntil

    public static void parkUntil(long deadline)
    Disables the current thread for thread scheduling purposes, until the specified deadline, unless the permit is available.

    If the permit is available then it is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

    • Some other thread invokes unpark with the current thread as the target; or
    • Some other thread interrupts the current thread; or
    • The specified deadline passes; or
    • The call spuriously (that is, for no reason) returns.

    This method does not report which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread, or the current time upon return.

    Parameters:
    deadline - the absolute time, in milliseconds from the Epoch, to wait until

java进程状态的更多相关文章

  1. Linux - 进程状态

    ps report a snapshot of the current processes. 能提供一份当前进程的快照,以列表的形式显示正在运行的进程. 列出进程的数量取决于命令所附加的参数,例如:p ...

  2. Linux - 查看进程状态

    ps命令 report a snapshot of the current processes. 能提供一份当前进程的快照,以列表的形式显示正在运行的进程. 列出进程的数量取决于命令所附加的参数,例如 ...

  3. 由Java正则表达式的灾难性回溯引发的高CPU异常:java.util.regex.Pattern$Loop.match

    问题与分析 某天领导report了一个问题:线上的CPU自从上一个版本迭代后就一直处于居高不下的状况,领导看着这段时间的曲线图判断是有两条线程在不停的死循环. 接到任务后去查看了AWS的CloudWa ...

  4. Java 集群高可用监控(结合阿里SLB)脚本

    欢迎点评,大家一起来优化 计划思路: 只有在mysql slave java 进程状态都正常的情况下才允许nginx 运行, 否则就干掉它, 负载用的是阿里的SLB #bin/bash #邮件函数  ...

  5. log4j的性能瓶颈定位与性能优化(org.apache.log4j.spi.RootLogger) (转)

    最近执行一个项目调优,发现使用第三方的Json库导致性能差.原以为问题就这么定位到了,结果去掉Json操作后,性能也不见好转. 现象非常诡异:CPU.内存.网络.磁盘使用率均有剩余,而且压力也是足够的 ...

  6. 测者的性能测试手册:JVM的监控利器

    测者的性能测试手册:JVM的监控利器 每次聊起性能测试,最后的终结话题就是怎么做优化.其实在Java的复杂项目中都会有内存不足问题.内存泄露问题.线程死锁问题.CPU问题.这些问题工程测试或者是小压力 ...

  7. CentOS下如何根据Dump文件分析线上问题

    https://blog.csdn.net/lixin03080/article/details/79711296 一.保存现场 1.记录系统整体资源使用情况,进程信息.线程信息 top -b -n ...

  8. Hadoop环境搭建 (伪分布式搭建)

    一,Hadoop版本下载 建议下载:Hadoop2.5.0 (虽然是老版本,但是在企业级别中运用非常稳定,新版本虽然添加了些小功能但是版本稳定性有带与考核) 1.下载地址: hadoop.apache ...

  9. Spark案例分析

    一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...

随机推荐

  1. python练习程序(c100经典例2)

    题目: 企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%:20万到40 ...

  2. spring的声明式事务内部图

  3. HDU2102 A计划

    解题思路:一道简单题,却WA了十几发,犯几个低级错误.还是不能急躁,     内心要平静,具体分析见代码: #include<iostream> #include<cstdio> ...

  4. MAC OSX 下安装Cscope

    续前文,搞定CTAGS之后,需要被搞定的是cscope,依旧是上网拖一把,具体过程如下   #1 下载cscope最新版本 http://cscope.sourceforge.net/#downloa ...

  5. 【转】gcc中-pthread和-lpthread的区别

    原文网址:http://chaoslawful.iteye.com/blog/568602 用gcc编译使用了POSIX thread的程序时通常需要加额外的选项,以便使用thread-safe的库及 ...

  6. 使用Rxjava缓存请求

    最近,我尝试使用RxJava开发了一款闲时备份app.我必须承认,一旦你get到了正确的方式,RxJava几乎感觉就像作弊.一切看起来更简洁,多个请求能够被组合,且非常容易控制.通过在UI线程观察和在 ...

  7. Android布局文件夹引起的问题

    Android 运行到setContentView(R.layout.splash); 总是出现如下的错误: java.lang.RuntimeException: Unable to start a ...

  8. 基于XMPP协议的手机多方多端即时通讯方案

    一.开发背景 1.国际背景 随着Internet技术的高速发展,即时通信已经成为一种广泛使用的通信方式.1996年Mirabilis公司推出了世界上第一个即时通信系统ICQ,不到10年间,即时通信(I ...

  9. Android开发中这些小技巧

    http://blog.csdn.net/guxiao1201/article/details/40655661 http://blog.csdn.net/guxiao1201/article/det ...

  10. Linux环境Weblogic10g服务部署

    1.先安装XManager: 2.进入XShell,远程连接Linux主机后,按如下操作即可打开XManager配置WebLogic部署服务: [root@server36 bin]# cd /[ro ...