jstack用于打印出给定的java进程ID或core file或远程调试服务的Java堆栈信息,如果是在64位机器上,需要指定选项"-J-d64",Windows的jstack使用方式只支持以下的这种方式。

例如说,通过:

ps ax | grep java

找到java的进程ID

jstack  

堆栈信息:

-- ::
Full thread dump Java HotSpot(TM) -Bit Server VM (24.71-b01 mixed mode):

 tid=0x00007fbce48bb000 nid=0x330b waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce528e800 nid=0x5903 waiting on condition [0x0000000118d05000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007d7610080> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.)
    at kafka.consumer.ZookeeperConsumerConnector$ZKRebalancerListener$$anon$.run(ZookeeperConsumerConnector.scala:)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce52ea000 nid=0x5703 waiting on condition [0x0000000118c02000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007d7600440> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:)
    at java.lang.Thread.run(Thread.java:)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce52e4800 nid=0x5503 waiting on condition [0x0000000118aff000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007d7608408> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:)
    at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce536e000 nid=0x5303 runnable [0x00000001189fc000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
    at sun.nio.ch.KQueueArrayWrapper.poll(KQueueArrayWrapper.java:)
    at sun.nio.ch.KQueueSelectorImpl.doSelect(KQueueSelectorImpl.java:)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:)
    - locked <)
    - locked <0x00000007d76101e0> (a java.util.Collections$UnmodifiableSet)
    - locked <0x00000007d7610180> (a sun.nio.ch.KQueueSelectorImpl)
    at sun.nio.ch.SelectorImpl.)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce52e3800 nid=0x5207 waiting on condition [0x00000001188f9000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007d7608500> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:)
    at org.I0Itec.zkclient.ZkEventThread.run(ZkEventThread.java:)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce5373000 nid=0x4b03 waiting on condition [0x00000001187f1000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007d76085f0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:)
    at java.lang.Thread.run(Thread.java:)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce539a000 nid=0x4903 waiting on condition [0x00000001186ee000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007d76085f0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:)
    at java.lang.Thread.run(Thread.java:)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce4022800 nid=0x4503 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce4021800 nid=0x4303 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce503b000 nid=0x4103 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce5035000 nid=0x3413 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce5032800 nid=0x2d03 in Object.wait() [0x0000000116146000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d7618ca0> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.)
    - locked <0x00000007d7618ca0> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.)
    at java.lang.)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce5031800 nid=0x2b03 in Object.wait() [0x0000000116043000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d76189c8> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:)
    at java.lang.)
    - locked <0x00000007d76189c8> (a java.lang.ref.Reference$Lock)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce5801000 nid=0x1303 waiting on condition [0x000000010c900000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007d760c9e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:)
    at kafka.consumer.ConsumerIterator.makeNext(ConsumerIterator.scala:)
    at kafka.consumer.ConsumerIterator.makeNext(ConsumerIterator.scala:)
    at kafka.utils.IteratorTemplate.maybeComputeNext(IteratorTemplate.scala:)
    at kafka.utils.IteratorTemplate.hasNext(IteratorTemplate.scala:)
    at KafkaConsumer.consume(KafkaConsumer.java:)
    at KafkaConsumer.main(KafkaConsumer.java:)

   Locked ownable synchronizers:
    - None

 tid=0x00007fbce502f000 nid=0x2903 runnable 

 tid=0x00007fbce5001800 nid=0x2103 runnable 

 tid=0x00007fbce5002000 nid=0x2303 runnable 

 tid=0x00007fbce5002800 nid=0x2503 runnable 

 tid=0x00007fbce4806000 nid=0x2703 runnable 

 tid=0x00007fbce401e800 nid=0x4703 waiting on condition 

JNI 

相关说明:

1.命令格式

jstack [ option ] pid
jstack [ option ] executable core
jstack [ option ] [server-id@]remote-hostname-or-IP

2、常用参数说明

1)options:

executable Java executable from which the core dump was produced.

(可能是产生core dump的java可执行程序)

core 将被打印信息的core dump文件

remote-hostname-or-IP 远程debug服务的主机名或ip

server-id 唯一id,假如一台主机上多个远程debug服务

2)基本参数:

-F当’jstack [-l] pid’没有相应的时候强制打印栈信息

-l长列表. 打印关于锁的附加信息,例如属于java.util.concurrent的ownable synchronizers列表.

-m打印java和native c/c++框架的所有栈信息.

-h | -help打印帮助信息

pid 需要被打印配置信息的java进程id,可以用jps查询.

有篇分析的文章写得特别的好,忍不住分享了:

http://jameswxx.iteye.com/blog/1041173

jstack命令(Java Stack Trace)的更多相关文章

  1. JDK内置工具jstack(Java Stack Trace)(转)

    1.介绍 jstack用于打印出给定的java进程ID或core file或远程调试服务的Java堆栈信息,如果是在64位机器上,需要指定选项"-J-d64",Windows的js ...

  2. 三、jdk工具之jstack(Java Stack Trace)

    目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...

  3. jmap命令(Java Memory Map)(转)

    JDK内置工具使用 一.javah命令(C Header and Stub File Generator) 二.jps命令(Java Virtual Machine Process Status To ...

  4. 给你的Java程序拍个片子吧:jstack命令解析

    前言 如果有一天,你的Java程序长时间停顿,也许是它病了,需要用jstack拍个片子分析分析,才能诊断具体什么病症,是死锁综合征,还是死循环等其他病症,本文我们一起来学习jstack命令~ jsta ...

  5. 十一、jdk命令之Jstatd命令(Java Statistics Monitoring Daemon)

    目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...

  6. 十一、jdk命令之Jstatd命令(Java Statistics Monitoring Daemon)远程的监控工具连接到本地的JVM执行命令

    目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...

  7. Java 抓取 thread dump (Full Thread Stack Trace) 方法汇总

    顾名思义,表示一个时间点上,显示进程里面每一个线程的 stack trace,以及线程之间关联,比如等待 常用来定位一些 不响应,CPU 很高,内存使用很高问题 汇总表格如下 工具 操作系统 Java ...

  8. Java的jstack命令使用详解

    jstack命令简介 jstack(Java Virtual Machine Stack Trace)是JDK提供的一个可以生成Java虚拟机当前时刻的线程快照信息的命令行工具.线程快照一般被称为th ...

  9. java jstack命令详解

    名称jstack: stack trace 摘要: jstack [ option ] pid jstack [ option ] executable core jstack [ option ] ...

随机推荐

  1. cmd批处理常用符号详解

    cmd批处理常用符号详解 作者: 字体:[增加 减小] 类型:转载 我们在批处理编写过程中经常遇到各种特殊符号,很多朋友不是很清楚cmd中特殊符号的含义,这里简单的介绍下,方便需要的朋友   1.@一 ...

  2. 搭建SpringMVC+Mybatis框架并实现数据库的操作

    User类 public class User { private Integer id; private String userName; private String password; priv ...

  3. editplus快捷键大全之editplus编辑快捷键

    前面我们说了editplus快捷键大全之editplus文件快捷键和editplus快捷键大全之editplus光标快捷键,这里我们讲一下editplus快捷键大全之editplus编辑快捷键 删除光 ...

  4. cocos2d调度器(定时执行某函数)

    调度器(scheduler) 继承关系 原理介绍 Cocos2d-x调度器为游戏提供定时事件和定时调用服务.所有Node对象都知道如何调度和取消调度事件,使用调度器有几个好处: 每当Node不再可见或 ...

  5. Stanford机器学习---第五讲. 神经网络的学习 Neural Networks learning

    原文 http://blog.csdn.net/abcjennifer/article/details/7758797 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回归 ...

  6. Android控件之圆形Button

    bg_circle.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns: ...

  7. MotionEvent常见值

    常见的动作常量: public static final int ACTION_DOWN        = 0;单点触摸动作 public static final int ACTION_UP     ...

  8. 用Maven插件生成Mybatis代码/数据库

    现在代码管理基本上是采用Maven管理,Maven的好处此处不多说,大家用百度搜索会有很多介绍,本文介绍一下用Maven工具如何生成Mybatis的代码及映射的文件. 一.配置Maven pom.xm ...

  9. poj2996 模拟

    Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3713   Accepted:  ...

  10. [ruby on rails] 跟我学之(3)基于rails console的查增删改操作

    本章节展开对model的介绍:包括查增删改操作.紧接着上面一节<[ruby on rails] 跟我学之HelloWorld> 创建模型 使用命令创建模型 创建表post,默认自带两栏位 ...