java进程状态

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
时间: 2024-08-01 06:45:40

java进程状态的相关文章

hbase shell 命令

1.首先要打开hbase,使用jps查看进程 jps是java进程状态工具,它会返回进程ID和服务名称 [email protected]:~/Apache/hbase-0.94.15-security$ jps 3082 NameNode 6245 HRegionServer 3493 JobTracker 6064 HMaster 5999 HQuorumPeer 3638 TaskTracker 3259 DataNode 3413 SecondaryNameNode 6320 Jps 2

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

最近执行一个项目调优,发现使用第三方的Json库导致性能差.原以为问题就这么定位到了,结果去掉Json操作后,性能也不见好转. 现象非常诡异:CPU.内存.网络.磁盘使用率均有剩余,而且压力也是足够的.即使施加更大压力,吞吐量也不见好转. 于是监控了一下Java进程状态,发现几乎所有进程都处在 状态:BLOCKED 在 [email protected] 上,拥有者: http-0.0.0.0-8080-2010 阻塞总数:188,661 等待总数: 2,699 堆栈追踪: org.apache

大华工作技术积累

基本linux操作命令: 查看端口:netstat -nltp|grep java 查看启用端口:netstat -anptu 本地传输文件到服务器:rz 服务器传输文件到本地:sz 压缩文件: zip -r a.zip b.text /home/appuser/hswx tar -xvf file.tar tar -zvxf file.tar.gz 解压zip文件: unzip a.zip 拷贝文件夹: cp -rf admin admin_2017.01.05 删除目录: rm -rf a

Java面试12|Linux及Shell脚本

1.关于awk命令的面试题 (1)最近登录的5个帐号 last -n 5 | awk -F ':'(指定域分割符号) '{print $1}' -n表示number,有多少行需要显示.读入有'\n'换行符分割的一条记录,然后将记录按指定的域分隔符划分域,填充域,$0则表示所有域,$1表示第一个域,$n表示第n个域.默认域分隔符是"空白键" 或 "[tab]键",所以$1表示登录用户,$3表示登录用户ip,以此类推. (2)用awk统计文本行数 awk '{count

Java 并发基础

Java 并发基础 线程简述 线程是进程的执行部分,用来完成一定的任务; 线程拥有自己的堆栈,程序计数器和自己的局部变量,但不拥有系统资源, 他与其他线程共享父进程的共享资源及部分运行时环境,因此编程时需要小心,确保线程不会妨碍同一进程中的其他线程; 多线程优势 进程之间不能共享内存,但线程之间共享内存/文件描述符/进程状态非常容易. 系统创建进程时需要为该其分配很多系统资源(如进程控制块),但创建线程的开销要小得多,因此线程实现多任务并发比进程效率高. Java语言内置多线程支持,而不是单纯采

Java线程小结

1.深入浅出Java多线程程序设计 多线程是这样一种机制,它允许在程序中并发执行多个指令流,每个指令流都称为一个线程,彼此间互相独立. 一:理解多线程 多线程是这样一种机制,它允许在程序中并发执行多个指令流,每个指令流都称为一个多线程是这样一种机制,它允许在程序中并发执行多个指令流,每个指令流都称为一个线程又称为轻量级进程,它和进程一样拥有独立的执行控制,由操作系统负责调度,区别在于线程没有独立的存储空间,而是和所属进程中的其它线程共享一个存储空间,这使得线程间的通信远较进程简单. 多个线程的执

Java调用本地命令

参考:http://blog.csdn.net/zhu_xun/article/details/19539513 http://www.cnblogs.com/kingcucumber/p/3180146.html 一.Process类 ProcessBuilder.start()创建一个本机进程,并返回一个Process子类的一个实例,该实例可以获取进程的相关信息,也可以控制进程.这个进程没有自己的终端,它的操作结果io都重定向到了它的父进程,父进程通过getInputStream(),get

Java问题定位工具

JDK本身提供了很多方便的JVM性能调优监控工具,除了集成式的VisualVM和jConsole外,还有jps.jstack.jmap.jhat.jstat.hprof等小巧的工具 现实企业级Java开发中,有时候我们会碰到下面这些问题: OutOfMemoryError,内存不足 内存泄露 线程死锁 锁争用(Lock Contention) Java进程消耗CPU过高 ...... 这些问题在日常开发中可能被很多人忽视(比如有的人遇到上面的问题只是重启服务器或者调大内存,而不会深究问题根源),

Java线上应用故障排查之一:高CPU占用

一个应用占用CPU很高,除了确实是计算密集型应用之外,通常原因都是出现了死循环. (友情提示:本博文章欢迎转载,但请注明出处:hankchen,http://www.blogjava.net/hankchen) 以我们最近出现的一个实际故障为例,介绍怎么定位和解决这类问题. 根据top命令,发现PID为28555的Java进程占用CPU高达200%,出现故障. 通过ps aux | grep PID命令,可以进一步确定是tomcat进程出现了问题.但是,怎么定位到具体线程或者代码呢? 首先显示线