jstack结果查看
⾸先可以⽤jstack -l pid >sample.dump把java进程的运⾏栈dump出来。
还可以⽤grep java.lang.Thread.State sample.dump | awk '{print $2}' | sort -n | uniq -c 来看看进程中都有哪些线程状态。
2019-01-2718:11:27
Full thread dump Java HotSpot(TM) 64-Bit Server VM (11.0.1+13-LTS mixed mode):
Threads class SMR info:
_java_thread_list=0x00007f8209356340, length=29, elements={
0x00007f8268174000, 0x00007f8268178000, 0x00007f826818a800, 0x00007f826818c800,
0x00007f826818f000, 0x00007f8268191000, 0x00007f826820f800, 0x00007f8268223000,
0x00007f8268011000, 0x00007f820817e000, 0x00007f8208180000, 0x00007f820830b800,
0x00007f8208409000, 0x00007f8208adc000, 0x00007f8208c08000, 0x00007f8208c48000,
0x00007f8208d24000, 0x00007f8208d25800, 0x00007f81c4466800, 0x00007f81c4469000,
0x00007f81c446a000, 0x00007f8208d0e800, 0x00007f81e001f800, 0x00007f81e0023000,
0x00007f821c040000, 0x00007f8238001800, 0x00007f820c1f2000, 0x00007f81d0004800,
0x00007f820928b000
}
"Reference Handler" #2 daemon prio=10 os_prio=0 cpu=15.09ms elapsed=19776.82s tid=0x00007f8268174000 nid=0x3f89
java.lang.Thread.State: RUNNABLE
at f.Reference.waitForReferencePendingList(java.base@11.0.1/Native Method)
at f.Reference.processPendingReferences(java.base@11.0.1/Reference.java:241)
at f.Reference$ReferenceHandler.run(java.base@11.0.1/Reference.java:213)
Locked ownable synchronizers:
- None
...
...
"fsnotifier64" #29 prio=4 os_prio=0 cpu=0.55ms elapsed=19772.56s tid=0x00007f81c4466800 nid=0x3fac in
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(java.base@11.0.1/Native Method)
- waiting on <0x00000000e3205e88> (a java.lang.ProcessImpl)
at java.lang.Object.wait(java.base@11.0.1/Object.java:328)
at java.lang.ProcessImpl.waitFor(java.base@11.0.1/ProcessImpl.java:495)
- waiting to re-lock in wait() <0x00000000e3205e88> (a java.lang.ProcessImpl)
at ution.process.ProcessWaitFor$1$1.run(ProcessWaitFor.java:52)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:229)
at ution.process.ProcessWaitFor$1.run(ProcessWaitFor.java:45)
at urrent.Executors$RunnableAdapter.call(java.base@11.0.1/Executors.java:515)
at urrent.FutureTask.run(java.base@11.0.1/FutureTask.java:264)
at urrent.ThreadPoolExecutor.runWorker(java.base@11.0.1/ThreadPoolExecutor.java:1128)
at urrent.ThreadPoolExecutor$Worker.run(java.base@11.0.1/ThreadPoolExecutor.java:628)
at java.lang.Thread.run(java.base@11.0.1/Thread.java:834)
Locked ownable synchronizers:
- <0x00000000e3205f78> (a urrent.ThreadPoolExecutor$Worker)
⾸先第⼀⾏显⽰的是dump的时间,第⼆⾏是虚拟机的⼀些信息,接着就是线程的list,包括每个线程
的tid。
紧接着就是最重要的线程栈了:
"Reference Handler":是线程的名字
#2不知道是啥,估计是线程列表中的的第⼏个线程?
daemon说明是守护线程
prio=10 os_prio=0 cpu=15.09ms elapsed=19776.82s 分别是线程jvm优先级,线程操作系统优先级,cpu运⾏时间,实际运⾏时间。
grep命令查看进程tid, Java memory address of its internal Thread control structure.16进制的
nid, native thread id. 每⼀个nid对应于linux下的⼀个tid, 即lwp  (light weight process, or thread).16进制的,转到10进制后可以⽤ps命令到它。
waiting on condition [0x00007f8248f2b000]  以及另⼀个线程的 Object.wait() [0x00007f81e41ac000]  线程运⾏到哪了,可以理解为线程pc 计数器的位置。
然后就是线程的状态。这个⼀般都是重点,可以看下《》,或者⽹上搜下怎么看jstack⽇志中的线程状态。
接着就是线程栈了,在线程栈中还会列出所之类的(以横杆-打头的)。
最后是Locked ownable synchronizers。
需要注意的是,⼀个java进程中,还有许多⾃带的线程⽐如gc线程啥的,所以你的单线程java可能也会有好多个线程dump出来,关于⾃带
的内部线程,参见《》⼀⽂。参考:《》
《》

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。