jstack命令打印指定Java进程、核心文件或远程调试服务器的Java线程的Java 栈跟踪。对于每个Java框架,将打印完整的类名、方法名、字节码索引(BCI)和行号(如果可用)。使用-m选项,jstack命令使用程序计数器(PC)打印所有线程的Java和本机帧。对于每个本机帧,打印距离PC最近的本机符号(如果可用)
全称: stack trace for java
形式:jstack -option pid
-F
Force a stack dump when jstack [-l] pid does not respond.
-l
Long listing. Prints additional information about locks such as a list of owned java.util.concurrent ownable synchronizers.
-m
Prints a mixed mode stack trace that has both Java and native C/C++ frames.
1,jstack -l 961012
长清单,打印关于锁的附加信息,例如拥有 JUC的 synchronizers 的一个list
jstack -l 961012 > jstack.txt
把锁信息的信息打印到一个文件去,方便查看。
2020-06-11 16:17:20
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode):
"Attach Listener" #14 daemon prio=9 os_prio=0 tid=0x00007ff514001000 nid=0x3f397 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"DestroyJavaVM" #13 prio=5 os_prio=0 tid=0x00007ff554008800 nid=0xea9f5 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"pool-1-thread-1" #12 prio=5 os_prio=0 tid=0x00007ff554378800 nid=0xeaa24 waiting on condition [0x00007ff52d6d9000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at periodical.MessageCreater.waitWrite(MessageCreater.java:429)
at periodical.MessageCreater.setNewGroupMsg(MessageCreater.java:341)
at ttmcreater.periodical.MessageCreater.run(MessageCreater.java:162)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Locked ownable synchronizers:
- <0x00000000c002b4a8> (a java.util.concurrent.ThreadPoolExecutor$Worker)
"Service Thread" #9 daemon prio=9 os_prio=0 tid=0x00007ff554219800 nid=0xeaa0a runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"C1 CompilerThread3" #8 daemon prio=9 os_prio=0 tid=0x00007ff55420e000 nid=0xeaa09 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"C2 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007ff55420c000 nid=0xeaa08 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007ff55420a000 nid=0xeaa07 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007ff554207000 nid=0xeaa06 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007ff554205800 nid=0xeaa05 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007ff5541d2800 nid=0xeaa04 in Object.wait() [0x00007ff5443f2000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000c002fa10> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
- locked <0x00000000c002fa10> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)
Locked ownable synchronizers:
- None
"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007ff5541ce000 nid=0xeaa03 in Object.wait() [0x00007ff5444f3000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
- locked <0x00000000c002f9e0> (a java.lang.ref.Reference$Lock)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)
Locked ownable synchronizers:
- None
"VM Thread" os_prio=0 tid=0x00007ff5541c6000 nid=0xeaa02 runnable
"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007ff55401e000 nid=0xea9f9 runnable
"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007ff55401f800 nid=0xea9fa runnable
"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007ff554021800 nid=0xea9fb runnable
"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007ff554023000 nid=0xea9fc runnable
"GC task thread#4 (ParallelGC)" os_prio=0 tid=0x00007ff554025000 nid=0xea9fd runnable
"GC task thread#5 (ParallelGC)" os_prio=0 tid=0x00007ff554027000 nid=0xea9ff runnable
"GC task thread#6 (ParallelGC)" os_prio=0 tid=0x00007ff554028800 nid=0xeaa00 runnable
"GC task thread#7 (ParallelGC)" os_prio=0 tid=0x00007ff55402a800 nid=0xeaa01 runnable
"VM Periodic Task Thread" os_prio=0 tid=0x00007ff55421c800 nid=0xeaa0b waiting on condition
JNI global references: 64
好像不太多,就粘这吧。
2,jstack -m 961012 >jstack2.flows
打印具有Java和本机C/ c++框架的混合模式堆栈跟踪。
Attaching to process ID 961012, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.131-b11
Deadlock Detection:
No deadlocks found.
----------------- 961013 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd800 _ZN7Monitor4waitEblb + 0x100
0x00007ff55c472621 _ZN7Threads10destroy_vmEv + 0x51
0x00007ff55c0cb8e1 jni_DestroyJavaVM + 0x81
0x00007ff55cfc763d JavaMain + 0x27d
----------------- 961017 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55bfd3f23 _ZN13GCTaskManager8get_taskEj + 0x43
0x00007ff55bfd4db8 _ZN12GCTaskThread3runEv + 0x188
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961018 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55bfd3f23 _ZN13GCTaskManager8get_taskEj + 0x43
0x00007ff55bfd4db8 _ZN12GCTaskThread3runEv + 0x188
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961019 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55bfd3f23 _ZN13GCTaskManager8get_taskEj + 0x43
0x00007ff55bfd4db8 _ZN12GCTaskThread3runEv + 0x188
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961020 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55bfd3f23 _ZN13GCTaskManager8get_taskEj + 0x43
0x00007ff55bfd4db8 _ZN12GCTaskThread3runEv + 0x188
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961021 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55bfd3f23 _ZN13GCTaskManager8get_taskEj + 0x43
0x00007ff55bfd4db8 _ZN12GCTaskThread3runEv + 0x188
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961023 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55bfd3f23 _ZN13GCTaskManager8get_taskEj + 0x43
0x00007ff55bfd4db8 _ZN12GCTaskThread3runEv + 0x188
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961024 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55bfd3f23 _ZN13GCTaskManager8get_taskEj + 0x43
0x00007ff55bfd4db8 _ZN12GCTaskThread3runEv + 0x188
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961025 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55bfd3f23 _ZN13GCTaskManager8get_taskEj + 0x43
0x00007ff55bfd4db8 _ZN12GCTaskThread3runEv + 0x188
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961026 -----------------
0x00007ff55d1e1d12 __pthread_cond_timedwait + 0x132
0x00007ff55c2dd38e _ZN7Monitor5IWaitEP6Threadl + 0x44e
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55c4cc029 _ZN8VMThread4loopEv + 0x339
0x00007ff55c4cc330 _ZN8VMThread3runEv + 0x70
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961027 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c30e655 _ZN13ObjectMonitor4waitElbP6Thread + 0xa65
0x00007ff55c121d52 JVM_MonitorWait + 0x182
0x00007ff545162568 <Unknown compiled code>
----------------- 961028 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c30e655 _ZN13ObjectMonitor4waitElbP6Thread + 0xa65
0x00007ff55c121d52 JVM_MonitorWait + 0x182
0x00007ff545162568 <Unknown compiled code>
----------------- 961029 -----------------
0x00007ff55d1e3adb do_futex_wait.constprop.1 + 0x2b
----------------- 961030 -----------------
0x00007ff55d1e1d12 __pthread_cond_timedwait + 0x132
0x00007ff55c2dd38e _ZN7Monitor5IWaitEP6Threadl + 0x44e
0x00007ff55c2dd9d6 _ZN7Monitor4waitEblb + 0x2d6
0x00007ff55beab3fb _ZN12CompileQueue3getEv + 0x13b
0x00007ff55bead64b _ZN13CompileBroker20compiler_thread_loopEv + 0x18b
0x00007ff55c472833 _ZN10JavaThread17thread_main_innerEv + 0x103
0x00007ff55c47297c _ZN10JavaThread3runEv + 0x11c
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961031 -----------------
0x00007ff55d1e1d12 __pthread_cond_timedwait + 0x132
0x00007ff55c2dd38e _ZN7Monitor5IWaitEP6Threadl + 0x44e
0x00007ff55c2dd9d6 _ZN7Monitor4waitEblb + 0x2d6
0x00007ff55beab3fb _ZN12CompileQueue3getEv + 0x13b
0x00007ff55bead64b _ZN13CompileBroker20compiler_thread_loopEv + 0x18b
0x00007ff55c472833 _ZN10JavaThread17thread_main_innerEv + 0x103
0x00007ff55c47297c _ZN10JavaThread3runEv + 0x11c
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961032 -----------------
0x00007ff55d1e1d12 __pthread_cond_timedwait + 0x132
0x00007ff55c2dd38e _ZN7Monitor5IWaitEP6Threadl + 0x44e
0x00007ff55c2dd9d6 _ZN7Monitor4waitEblb + 0x2d6
0x00007ff55beab3fb _ZN12CompileQueue3getEv + 0x13b
0x00007ff55bead64b _ZN13CompileBroker20compiler_thread_loopEv + 0x18b
0x00007ff55c472833 _ZN10JavaThread17thread_main_innerEv + 0x103
0x00007ff55c47297c _ZN10JavaThread3runEv + 0x11c
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961033 -----------------
0x00007ff55d1e1d12 __pthread_cond_timedwait + 0x132
0x00007ff55c2dd38e _ZN7Monitor5IWaitEP6Threadl + 0x44e
0x00007ff55c2dd9d6 _ZN7Monitor4waitEblb + 0x2d6
0x00007ff55beab3fb _ZN12CompileQueue3getEv + 0x13b
0x00007ff55bead64b _ZN13CompileBroker20compiler_thread_loopEv + 0x18b
0x00007ff55c472833 _ZN10JavaThread17thread_main_innerEv + 0x103
0x00007ff55c47297c _ZN10JavaThread3runEv + 0x11c
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961034 -----------------
0x00007ff55d1e1965 __pthread_cond_wait + 0xc5
0x00007ff55c2dd037 _ZN7Monitor5IWaitEP6Threadl + 0xf7
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55c3bca58 _ZN13ServiceThread20service_thread_entryEP10JavaThreadP6Thread + 0x398
0x00007ff55c472833 _ZN10JavaThread17thread_main_innerEv + 0x103
0x00007ff55c47297c _ZN10JavaThread3runEv + 0x11c
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961035 -----------------
0x00007ff55d1e1d12 __pthread_cond_timedwait + 0x132
0x00007ff55c2dd38e _ZN7Monitor5IWaitEP6Threadl + 0x44e
0x00007ff55c2dd956 _ZN7Monitor4waitEblb + 0x256
0x00007ff55c46bce1 _ZNK13WatcherThread5sleepEv + 0x71
0x00007ff55c46d51e _ZN13WatcherThread3runEv + 0x5e
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961060 -----------------
0x00007ff55d1e1d12 __pthread_cond_timedwait + 0x132
0x00007ff55c3238f3 _ZN2os5sleepEP6Threadlb + 0x283
0x00007ff55c120bda JVM_Sleep + 0x3ba
0x00007ff545353db1 <Unknown compiled code>
----------------- 258967 -----------------
0x00007ff55d1e497d __libc_accept + 0x2d
0x00007ff55bd1a22e _ZN14AttachListener7dequeueEv + 0x9e
0x00007ff55bd1913a _ZL28attach_listener_thread_entryP10JavaThreadP6Thread + 0x19a
0x00007ff55c472833 _ZN10JavaThread17thread_main_innerEv + 0x103
0x00007ff55c47297c _ZN10JavaThread3runEv + 0x11c
0x00007ff55c323568 _ZL10java_startP6Thread + 0x108
----------------- 961012 -----------------
0x00007ff55d1def47 pthread_join + 0xa7
也不太多,也粘贴出来看看。
这个放眼望去,可读性太不好了,连个类每啥的都没有,全是地址。。。
难。