标签:单线程 color condition imp 显示 tsp reference 状态 handle
首先可以用jstack -l pid >sample.dump把java进程的运行栈dump出来。
还可以用grep java.lang.Thread.State sample.dump | awk ‘{print $2}‘ | sort -n | uniq -c 来看看进程中都有哪些线程状态。
2019-01-27 18: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 java.lang.ref.Reference.waitForReferencePendingList(java.base@11.0.1/Native Method) at java.lang.ref.Reference.processPendingReferences(java.base@11.0.1/Reference.java:241) at java.lang.ref.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 com.intellij.execution.process.ProcessWaitFor$1$1.run(ProcessWaitFor.java:52) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:229) at com.intellij.execution.process.ProcessWaitFor$1.run(ProcessWaitFor.java:45) at java.util.concurrent.Executors$RunnableAdapter.call(java.base@11.0.1/Executors.java:515) at java.util.concurrent.FutureTask.run(java.base@11.0.1/FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.1/ThreadPoolExecutor.java:1128) at java.util.concurrent.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 java.util.concurrent.ThreadPoolExecutor$Worker)
首先第一行显示的是dump的时间,第二行是虚拟机的一些信息,接着就是线程的list,包括每个线程的tid。
紧接着就是最重要的线程栈了:
"Reference Handler":是线程的名字
#2不知道是啥,估计是线程列表中的的第几个线程?
daemon说明是守护线程
prio=10 os_prio=0 cpu=15.09ms elapsed=19776.82s 分别是线程jvm优先级,线程操作系统优先级,cpu运行时间,实际运行时间。
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 Dump 日志》,或者网上搜下怎么看jstack日志中的线程状态。
接着就是线程栈了,在线程栈中还会列出所之类的(以横杆-打头的)。
最后是Locked ownable synchronizers。
需要注意的是,一个java进程中,还有许多自带的线程比如gc线程啥的,所以你的单线程java可能也会有好多个线程dump出来,关于自带的内部线程,参见《JVM内部运行线程介绍》一文。
标签:单线程 color condition imp 显示 tsp reference 状态 handle
原文地址:https://www.cnblogs.com/JMLiu/p/10327675.html