原创

[docker]jstack使用

jstack

jstack prints Java stack traces of Java threads for a given Java process or core file or a remote debug server. For each Java frame, the full class name, method name, 'bci' (byte code index) and line number, if available, are printed. With the -m option, jstack prints both Java and native frames of all threads along with the 'pc' (program counter). For each native frame, the closest native symbol to 'pc', if available, is printed. C++ mangled names are not demangled. To demangle C++ names, the output of this command may be piped to c++filt. If the given process is running on a 64-bit VM, you may need to specify the -J-d64 option, e.g.:

jstack 用于打印java堆栈.让开发人员更好的分析系统的性能瓶颈.

使用

简易使用命令jstack [pid] 即可

当然首先要找到java进程,知道pid才行,使用命令ps -ef | grep java

解析

以下为例子

"BLOG-ARTICLE_LOOK-0" #44 prio=5 os_prio=0 tid=0x00007f64752b6000 nid=0x36 waiting on condition [0x00007f63e34f5000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000c3d54c28> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
    at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:403)
    *******************
    at java.lang.Thread.run(Thread.java:748)

"BLOG-ARTICLE_LOOK-0" #44 prio=5 os_prio=0 tid=0x00007f64752b6000 nid=0x36 waiting on condition [0x00007f63e34f5000]

"BLOG-ARTICLE_LOOK-0" 代表线程名称

#44 线程编号ID
prio=5 优先级
os_prio=0 操作系统优先级
tid=0x00007f64752b6000 java线程地址
nid=0x36 OS线程ID
waiting on condition 线程状态
[0x00007f63e34f5000] 最新的堆栈指针

   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000c3d54c28> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
    at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:403)
    *******************
    at java.lang.Thread.run(Thread.java:748)

这些就是堆栈的信息

这样就能知道线程当前的状态,能协助我们判断程序问题了.

参考

  1. jstack - Stack Trace
  2. JDK14性能管理工具之jstack使用介绍

本文来自:[docker]jstack使用-小码农,转载请保留本条链接,感谢!

温馨提示:
本文最后更新于 2022年04月18日,已超过 962 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我
正文到此结束
本文目录