[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)
这些就是堆栈的信息
这样就能知道线程当前的状态,能协助我们判断程序问题了.
参考
本文来自:[docker]jstack使用-小码农,转载请保留本条链接,感谢!
- 本文标签: linux docker java
- 本文链接: https://djc8.cn/archives/docker-jstack-uses.html
- 版权声明: 本文由小码农原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权