当前位置:首页 > 开发 > 编程语言 > Java > 正文

【Java命令三】jstack

发表于: 2015-03-07   作者:bit1129   来源:转载   浏览:
摘要: jstack是用于获得当前运行的Java程序所有的线程的运行情况(thread dump),不同于jmap用于获得memory dump   [hadoop@hadoop sbin]$ jstack Usage: jstack [-l] <pid> (to connect to running process) jstack -F

jstack是用于获得当前运行的Java程序所有的线程的运行情况(thread dump),不同于jmap用于获得memory dump

 

[hadoop@hadoop sbin]$ jstack
Usage:
    jstack [-l] <pid>
        (to connect to running process)
    jstack -F [-m] [-l] <pid>
        (to connect to a hung process)
    jstack [-m] [-l] <executable> <core>
        (to connect to a core file)
    jstack [-m] [-l] [server_id@]<remote server IP or hostname>
        (to connect to a remote debug server)

Options:
    -F  to force a thread dump. Use when jstack <pid> does not respond (process is hung)
    -m  to print both java and native frames (mixed mode)
    -l  long listing. Prints additional information about locks
    -h or -help to print this help message

 

 常用参数:-F和-l,-F用于强制dump,-l用于获取一些关于锁的详细信息

 

 样例:

如下是使用jstack -l pid > thread.dump.001获得的输出,其中Locked ownable synchronizers是-l产生的,不加-l参数则不会输出

2015-02-27 05:37:00
Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode):

"sparkMaster-akka.remote.default-remote-dispatcher-55" daemon prio=10 tid=0x00007ff990001800 nid=0xc03 waiting on condition [0x00007ff9ad5d2000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000fd77df70> (a akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinPool)
        at scala.concurrent.forkjoin.ForkJoinPool.idleAwaitWork(ForkJoinPool.java:2135)
        at scala.concurrent.forkjoin.ForkJoinPool.scan(ForkJoinPool.java:2067)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

   Locked ownable synchronizers:
        - None

"sparkMaster-akka.actor.default-dispatcher-46" daemon prio=10 tid=0x00007ff988008000 nid=0xb2a waiting on condition [0x00007ff9adad7000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000fd77ed20> (a akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinPool)
        at scala.concurrent.forkjoin.ForkJoinPool.scan(ForkJoinPool.java:2075)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

   Locked ownable synchronizers:
        - None

"Attach Listener" daemon prio=10 tid=0x00007ff9a800d800 nid=0x995 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
        - None

"qtp984535779-33" daemon prio=10 tid=0x00007ff98c078800 nid=0x833 waiting on condition [0x00007ff9ac2a3000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000fd781130> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
        at org.eclipse.jetty.util.BlockingArrayQueue.poll(BlockingArrayQueue.java:342)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.idleJobPoll(QueuedThreadPool.java:526)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.access$600(QueuedThreadPool.java:44)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)

 

 

 

【Java命令三】jstack

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
1、介绍 jstack用于打印出给定的 java 进程 ID 或 core file 或远程调试服务的 Java 堆栈信息,如果
JDK内置工具使用 一、javah命令(CHeaderandStubFileGenerator) 二、jps命令(JavaVirtualMachineProc
JDK内置工具使用 一、javah命令(C Header and Stub File Generator) 二、jps命令(Java Virtual Mach
JDK内置工具使用 一、javah命令(C Header and Stub File Generator) 二、jps命令(Java Virtual Mach
JDK内置工具使用 一、javah命令(C Header and Stub File Generator) 二、jps命令(Java Virtual Mach
jstack命令 该命令打印java线程的堆栈跟踪,可以得知哪些线程被阻塞或正等待,以便于查找如线程死锁
1.介绍 Stack Trace for Java,用于生成虚拟机当前的线程快照信息,包含每一条线程的堆栈信息。该命
1.介绍 Stack Trace for Java,用于生成虚拟机当前的线程快照信息,包含每一条线程的堆栈信息。该命
jstack命令 该命令打印java线程的堆栈跟踪,可以得知哪些线程被阻塞或正等待,以便于查找如线程死锁
10 jstack
Java 的线程 线程是指能独立于程序的其它部分运行的执行单元。 JAVA语言能够很好的实现多线程的程序
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号