编程语言
首页 > 编程语言> > java 15:用jstack查看线程信息

java 15:用jstack查看线程信息

作者:互联网

一,jstack查看帮助:

[lhdop@blog ~]$ jstack --help
Usage:
    jstack [-l][-e] <pid>
        (to connect to running process)
 
Options:
    -l  long listing. Prints additional information about locks
    -e  extended listing. Prints additional information about threads
    -? -h --help -help to print this help message
-l  打印锁的额外信息 -e 打印线程的附加信息  

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

 

二,jstack使用例子:

1,得到进程id
[lhdop@blog ~]$ jps
28640 Jps
20756 storeback-0.0.1-SNAPSHOT.jar

2,查看线程信息: 

[lhdop@blog ~]$ jstack 20756
2022-03-20 20:42:51
Full thread dump Java HotSpot(TM) 64-Bit Server VM (15+36-1562 mixed mode, sharing):
 
Threads class SMR info:
_java_thread_list=0x00007f458c68c550, length=30, elements={
0x00007f45e019f010, 0x00007f45e01a0750, 0x00007f45e01a9f40, 0x00007f45e01ab650,
0x00007f45e01ad270, 0x00007f45e01aeaa0, 0x00007f45e01b01a0, 0x00007f45e0205510,
0x00007f45e0208b50, 0x00007f45e0b0e850, 0x00007f45e0506880, 0x00007f45e104cdc0,
0x00007f45500030f0, 0x00007f45e0303ad0, 0x00007f45e170d7a0, 0x00007f45e1710c60,
0x00007f45e17202c0, 0x00007f45e0028a10, 0x00007f454409a8f0, 0x00007f454c007230,
0x00007f454c004cb0, 0x00007f454c0029c0, 0x00007f454c007930, 0x00007f454c008ad0,
0x00007f454c00db20, 0x00007f454c005ca0, 0x00007f454c006550, 0x00007f454c00ed80,
0x00007f454c00ff30, 0x00007f4594000ce0
}
 
"Reference Handler" #2 daemon prio=10 os_prio=0 cpu=5.07ms elapsed=187206.42s tid=0x00007f45e019f010 nid=0x511c waiting on condition  [0x00007f45e42d4000]
   java.lang.Thread.State: RUNNABLE
        at java.lang.ref.Reference.waitForReferencePendingList(java.base@15/Native Method)
        at java.lang.ref.Reference.processPendingReferences(java.base@15/Reference.java:241)
        at java.lang.ref.Reference$ReferenceHandler.run(java.base@15/Reference.java:213)
 
"Finalizer" #3 daemon prio=8 os_prio=0 cpu=0.20ms elapsed=187206.42s tid=0x00007f45e01a0750 nid=0x511d in Object.wait()  [0x00007f45e41d3000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(java.base@15/Native Method)
        - waiting on <0x0000000710800c68> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(java.base@15/ReferenceQueue.java:155)
        - locked <0x0000000710800c68> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(java.base@15/ReferenceQueue.java:176)
        at java.lang.ref.Finalizer$FinalizerThread.run(java.base@15/Finalizer.java:170)
 
"Signal Dispatcher" #4 daemon prio=9 os_prio=0 cpu=0.24ms elapsed=187206.41s tid=0x00007f45e01a9f40 nid=0x511e runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"Service Thread" #5 daemon prio=9 os_prio=0 cpu=2151.91ms elapsed=187206.41s tid=0x00007f45e01ab650 nid=0x511f runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"C2 CompilerThread0" #6 daemon prio=9 os_prio=0 cpu=12427.80ms elapsed=187206.41s tid=0x00007f45e01ad270 nid=0x5120 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   No compile task
 
"C1 CompilerThread0" #8 daemon prio=9 os_prio=0 cpu=4189.22ms elapsed=187206.41s tid=0x00007f45e01aeaa0 nid=0x5121 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   No compile task
 
"Sweeper thread" #9 daemon prio=9 os_prio=0 cpu=97.32ms elapsed=187206.41s tid=0x00007f45e01b01a0 nid=0x5122 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"Notification Thread" #10 daemon prio=9 os_prio=0 cpu=0.05ms elapsed=187206.40s tid=0x00007f45e0205510 nid=0x5123 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"Common-Cleaner" #11 daemon prio=8 os_prio=0 cpu=86.83ms elapsed=187206.40s tid=0x00007f45e0208b50 nid=0x5125 in Object.wait()  [0x00007f45c0b92000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(java.base@15/Native Method)
        - waiting on <no object reference available>
        at java.lang.ref.ReferenceQueue.remove(java.base@15/ReferenceQueue.java:155)
        - locked <0x0000000710800f90> (a java.lang.ref.ReferenceQueue$Lock)
        at jdk.internal.ref.CleanerImpl.run(java.base@15/CleanerImpl.java:148)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
        at jdk.internal.misc.InnocuousThread.run(java.base@15/InnocuousThread.java:134)
 
"Log4j2-TF-10-AsyncLoggerConfig-2" #16 daemon prio=5 os_prio=0 cpu=161145.55ms elapsed=187204.61s tid=0x00007f45e0b0e850 nid=0x512e waiting on condition  [0x00007f45c057f000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710801858> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(java.base@15/LockSupport.java:252)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(java.base@15/AbstractQueuedSynchronizer.java:1661)
        at com.lmax.disruptor.TimeoutBlockingWaitStrategy.waitFor(TimeoutBlockingWaitStrategy.java:38)
        at com.lmax.disruptor.ProcessingSequenceBarrier.waitFor(ProcessingSequenceBarrier.java:56)
        at com.lmax.disruptor.BatchEventProcessor.processEvents(BatchEventProcessor.java:159)
        at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:125)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"mysql-cj-abandoned-connection-cleanup" #19 daemon prio=5 os_prio=0 cpu=2381.28ms elapsed=187202.91s tid=0x00007f45e0506880 nid=0x5132 in Object.wait()  [0x00007f45c0a91000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(java.base@15/Native Method)
        - waiting on <no object reference available>
        at java.lang.ref.ReferenceQueue.remove(java.base@15/ReferenceQueue.java:155)
        - locked <0x0000000711b2a710> (a java.lang.ref.ReferenceQueue$Lock)
        at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@15/ThreadPoolExecutor.java:1130)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@15/ThreadPoolExecutor.java:630)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"Catalina-utility-1" #20 prio=1 os_prio=0 cpu=5639.35ms elapsed=187202.42s tid=0x00007f45e104cdc0 nid=0x5135 waiting on condition  [0x00007f45b0150000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000711b2ed88> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(java.base@15/ScheduledThreadPoolExecutor.java:1177)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(java.base@15/ScheduledThreadPoolExecutor.java:899)
        at java.util.concurrent.ThreadPoolExecutor.getTask(java.base@15/ThreadPoolExecutor.java:1056)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@15/ThreadPoolExecutor.java:1116)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@15/ThreadPoolExecutor.java:630)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"Catalina-utility-2" #21 prio=1 os_prio=0 cpu=5816.00ms elapsed=187202.42s tid=0x00007f45500030f0 nid=0x5136 waiting on condition  [0x00007f4562efa000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000711b2ed88> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(java.base@15/LockSupport.java:252)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(java.base@15/AbstractQueuedSynchronizer.java:1661)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(java.base@15/ScheduledThreadPoolExecutor.java:1182)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(java.base@15/ScheduledThreadPoolExecutor.java:899)
        at java.util.concurrent.ThreadPoolExecutor.getTask(java.base@15/ThreadPoolExecutor.java:1056)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@15/ThreadPoolExecutor.java:1116)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@15/ThreadPoolExecutor.java:630)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"container-0" #22 prio=5 os_prio=0 cpu=356.38ms elapsed=187202.42s tid=0x00007f45e0303ad0 nid=0x5137 waiting on condition  [0x00007f4562df9000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
        at java.lang.Thread.sleep(java.base@15/Native Method)
        at org.apache.catalina.core.StandardServer.await(StandardServer.java:563)
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer$1.run(TomcatWebServer.java:197)
 
"http-nio-10800-Poller" #23 daemon prio=5 os_prio=0 cpu=4016.53ms elapsed=187201.75s tid=0x00007f45e170d7a0 nid=0x5138 runnable  [0x00007f45626f6000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPoll.wait(java.base@15/Native Method)
        at sun.nio.ch.EPollSelectorImpl.doSelect(java.base@15/EPollSelectorImpl.java:120)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(java.base@15/SelectorImpl.java:129)
        - locked <0x0000000710c07008> (a sun.nio.ch.Util$2)
        - locked <0x0000000710c07018> (a sun.nio.ch.EPollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(java.base@15/SelectorImpl.java:141)
        at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:787)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-Acceptor" #24 daemon prio=5 os_prio=0 cpu=20.01ms elapsed=187201.75s tid=0x00007f45e1710c60 nid=0x5139 runnable  [0x00007f45625f5000]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.Net.accept(java.base@15/Native Method)
        at sun.nio.ch.ServerSocketChannelImpl.accept(java.base@15/ServerSocketChannelImpl.java:305)
        at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:540)
        at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:78)
        at org.apache.tomcat.util.net.Acceptor.run(Acceptor.java:106)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"scheduling-1" #25 prio=5 os_prio=0 cpu=1282.91ms elapsed=187201.74s tid=0x00007f45e17202c0 nid=0x513a waiting on condition  [0x00007f45624f4000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710c07280> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(java.base@15/LockSupport.java:252)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(java.base@15/AbstractQueuedSynchronizer.java:1661)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(java.base@15/ScheduledThreadPoolExecutor.java:1182)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(java.base@15/ScheduledThreadPoolExecutor.java:899)
        at java.util.concurrent.ThreadPoolExecutor.getTask(java.base@15/ThreadPoolExecutor.java:1056)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@15/ThreadPoolExecutor.java:1116)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@15/ThreadPoolExecutor.java:630)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"DestroyJavaVM" #26 prio=5 os_prio=0 cpu=4304.97ms elapsed=187201.74s tid=0x00007f45e0028a10 nid=0x5115 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"HikariPool-1 housekeeper" #27 daemon prio=5 os_prio=0 cpu=499.97ms elapsed=186771.10s tid=0x00007f454409a8f0 nid=0x5164 waiting on condition  [0x00007f45621f2000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710f74570> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(java.base@15/LockSupport.java:252)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(java.base@15/AbstractQueuedSynchronizer.java:1661)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(java.base@15/ScheduledThreadPoolExecutor.java:1182)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(java.base@15/ScheduledThreadPoolExecutor.java:899)
        at java.util.concurrent.ThreadPoolExecutor.getTask(java.base@15/ThreadPoolExecutor.java:1056)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@15/ThreadPoolExecutor.java:1116)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@15/ThreadPoolExecutor.java:630)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-1" #197 daemon prio=5 os_prio=0 cpu=215.99ms elapsed=162530.12s tid=0x00007f454c007230 nid=0x5519 waiting on condition  [0x00007f45620f1000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-2" #198 daemon prio=5 os_prio=0 cpu=244.82ms elapsed=162530.12s tid=0x00007f454c004cb0 nid=0x551a waiting on condition  [0x00007f4561dee000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-3" #199 daemon prio=5 os_prio=0 cpu=322.76ms elapsed=162526.77s tid=0x00007f454c0029c0 nid=0x551b waiting on condition  [0x00007f4561aea000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-4" #200 daemon prio=5 os_prio=0 cpu=219.90ms elapsed=162525.74s tid=0x00007f454c007930 nid=0x551c waiting on condition  [0x00007f45617e6000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-5" #201 daemon prio=5 os_prio=0 cpu=48.59ms elapsed=162523.50s tid=0x00007f454c008ad0 nid=0x551d waiting on condition  [0x00007f45616e5000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-6" #202 daemon prio=5 os_prio=0 cpu=68.88ms elapsed=162521.76s tid=0x00007f454c00db20 nid=0x551e waiting on condition  [0x00007f45613e2000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-7" #741 daemon prio=5 os_prio=0 cpu=39.10ms elapsed=104690.97s tid=0x00007f454c005ca0 nid=0x5d93 waiting on condition  [0x00007f45612e1000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-8" #742 daemon prio=5 os_prio=0 cpu=46.43ms elapsed=104690.97s tid=0x00007f454c006550 nid=0x5d94 waiting on condition  [0x00007f45611e0000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-9" #743 daemon prio=5 os_prio=0 cpu=52.64ms elapsed=104678.06s tid=0x00007f454c00ed80 nid=0x5d96 waiting on condition  [0x00007f45610df000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"http-nio-10800-exec-10" #744 daemon prio=5 os_prio=0 cpu=71.55ms elapsed=104640.96s tid=0x00007f454c00ff30 nid=0x5d9b waiting on condition  [0x00007f4560fde000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@15/Native Method)
        - parking to wait for  <0x0000000710dd9760> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@15/LockSupport.java:341)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@15/AbstractQueuedSynchronizer.java:505)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@15/ForkJoinPool.java:3137)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@15/AbstractQueuedSynchronizer.java:1614)
        at java.util.concurrent.LinkedBlockingQueue.take(java.base@15/LinkedBlockingQueue.java:435)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:146)
        at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:33)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1114)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(java.base@15/Thread.java:832)
 
"Attach Listener" #965 daemon prio=9 os_prio=0 cpu=0.67ms elapsed=80179.40s tid=0x00007f4594000ce0 nid=0x6401 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
 
"VM Thread" os_prio=0 cpu=2218.16ms elapsed=187206.42s tid=0x00007f45e019c300 nid=0x511b runnable
 
"GC Thread#0" os_prio=0 cpu=177.34ms elapsed=187206.43s tid=0x00007f45e0076580 nid=0x5116 runnable
 
"GC Thread#1" os_prio=0 cpu=166.08ms elapsed=187206.20s tid=0x00007f45a8000f30 nid=0x5127 runnable
 
"GC Thread#2" os_prio=0 cpu=178.28ms elapsed=187206.19s tid=0x00007f45a8001c90 nid=0x5128 runnable
 
"GC Thread#3" os_prio=0 cpu=174.83ms elapsed=187206.19s tid=0x00007f45a8002a20 nid=0x512a runnable
 
"G1 Main Marker" os_prio=0 cpu=1.46ms elapsed=187206.43s tid=0x00007f45e0086ee0 nid=0x5117 runnable
 
"G1 Conc#0" os_prio=0 cpu=186.57ms elapsed=187206.43s tid=0x00007f45e0088170 nid=0x5118 runnable
 
"G1 Refine#0" os_prio=0 cpu=40.57ms elapsed=187206.43s tid=0x00007f45e0127000 nid=0x5119 runnable
 
"G1 Refine#1" os_prio=0 cpu=10.51ms elapsed=187204.62s tid=0x00007f45ac002e40 nid=0x512d runnable
 
"G1 Refine#2" os_prio=0 cpu=0.16ms elapsed=187204.34s tid=0x00007f4564001420 nid=0x5130 runnable
 
"G1 Refine#3" os_prio=0 cpu=0.05ms elapsed=187202.68s tid=0x00007f455c000ce0 nid=0x5133 runnable
 
"G1 Young RemSet Sampling" os_prio=0 cpu=13952.14ms elapsed=187206.43s tid=0x00007f45e0128210 nid=0x511a runnable
 
"VM Periodic Task Thread" os_prio=0 cpu=33512.67ms elapsed=187206.40s tid=0x00007f45e02073f0 nid=0x5124 waiting on condition
 
JNI global refs: 15, weak refs: 0

 

三,jstack中的nid是什么?

nid 是这个线程对应的操作系统本地线程id,         每一个java线程都对应一个操作系统线程 我们来验证一下:
[lhdop@blog ~]$ pidstat -t -p 20756
Linux 4.18.0-80.11.2.el8_0.x86_64 (blog)        03/20/2022      _x86_64_        (4 CPU)
 
08:44:52 PM   UID      TGID       TID    %usr %system  %guest   %wait    %CPU   CPU  Command
08:44:52 PM  1000     20756         -    0.00    0.00    0.00    0.00    0.00     1  java
08:44:52 PM  1000         -     20756    0.00    0.00    0.00    0.00    0.00     1  |__java
08:44:52 PM  1000         -     20757    0.00    0.00    0.00    0.00    0.00     0  |__java
08:44:52 PM  1000         -     20758    0.00    0.00    0.00    0.00    0.00     3  |__GC Thread#0
08:44:52 PM  1000         -     20759    0.00    0.00    0.00    0.00    0.00     2  |__G1 Main Marker
08:44:52 PM  1000         -     20760    0.00    0.00    0.00    0.00    0.00     0  |__G1 Conc#0
08:44:52 PM  1000         -     20761    0.00    0.00    0.00    0.00    0.00     1  |__G1 Refine#0
08:44:52 PM  1000         -     20762    0.00    0.00    0.00    0.00    0.00     1  |__G1 Young RemSet
08:44:52 PM  1000         -     20763    0.00    0.00    0.00    0.00    0.00     1  |__VM Thread
08:44:52 PM  1000         -     20764    0.00    0.00    0.00    0.00    0.00     0  |__Reference Handl
08:44:52 PM  1000         -     20765    0.00    0.00    0.00    0.00    0.00     1  |__Finalizer
08:44:52 PM  1000         -     20766    0.00    0.00    0.00    0.00    0.00     1  |__Signal Dispatch
08:44:52 PM  1000         -     20767    0.00    0.00    0.00    0.00    0.00     3  |__Service Thread
08:44:52 PM  1000         -     20768    0.00    0.00    0.00    0.00    0.00     1  |__C2 CompilerThre
08:44:52 PM  1000         -     20769    0.00    0.00    0.00    0.00    0.00     0  |__C1 CompilerThre
08:44:52 PM  1000         -     20770    0.00    0.00    0.00    0.00    0.00     0  |__Sweeper thread
08:44:52 PM  1000         -     20771    0.00    0.00    0.00    0.00    0.00     1  |__Notification Th
08:44:52 PM  1000         -     20772    0.00    0.00    0.00    0.00    0.00     2  |__VM Periodic Tas
08:44:52 PM  1000         -     20773    0.00    0.00    0.00    0.00    0.00     0  |__Common-Cleaner
08:44:52 PM  1000         -     20775    0.00    0.00    0.00    0.00    0.00     0  |__GC Thread#1
08:44:52 PM  1000         -     20776    0.00    0.00    0.00    0.00    0.00     3  |__GC Thread#2
08:44:52 PM  1000         -     20778    0.00    0.00    0.00    0.00    0.00     3  |__GC Thread#3
08:44:52 PM  1000         -     20781    0.00    0.00    0.00    0.00    0.00     0  |__G1 Refine#1
08:44:52 PM  1000         -     20782    0.00    0.00    0.00    0.00    0.00     1  |__Log4j2-TF-10-As
08:44:52 PM  1000         -     20784    0.00    0.00    0.00    0.00    0.00     0  |__G1 Refine#2
08:44:52 PM  1000         -     20786    0.00    0.00    0.00    0.00    0.00     3  |__mysql-cj-abando
08:44:52 PM  1000         -     20787    0.00    0.00    0.00    0.00    0.00     2  |__G1 Refine#3
08:44:52 PM  1000         -     20789    0.00    0.00    0.00    0.00    0.00     2  |__Catalina-utilit
08:44:52 PM  1000         -     20790    0.00    0.00    0.00    0.00    0.00     0  |__Catalina-utilit
08:44:52 PM  1000         -     20791    0.00    0.00    0.00    0.00    0.00     0  |__container-0
08:44:52 PM  1000         -     20792    0.00    0.00    0.00    0.00    0.00     3  |__http-nio-10800-
08:44:52 PM  1000         -     20793    0.00    0.00    0.00    0.00    0.00     0  |__http-nio-10800-
08:44:52 PM  1000         -     20794    0.00    0.00    0.00    0.00    0.00     0  |__scheduling-1
08:44:52 PM  1000         -     20836    0.00    0.00    0.00    0.00    0.00     0  |__HikariPool-1 ho
08:44:52 PM  1000         -     21785    0.00    0.00    0.00    0.00    0.00     0  |__http-nio-10800-
08:44:52 PM  1000         -     21786    0.00    0.00    0.00    0.00    0.00     0  |__http-nio-10800-
08:44:52 PM  1000         -     21787    0.00    0.00    0.00    0.00    0.00     0  |__http-nio-10800-
08:44:52 PM  1000         -     21788    0.00    0.00    0.00    0.00    0.00     3  |__http-nio-10800-
08:44:52 PM  1000         -     21789    0.00    0.00    0.00    0.00    0.00     1  |__http-nio-10800-
08:44:52 PM  1000         -     21790    0.00    0.00    0.00    0.00    0.00     0  |__http-nio-10800-
08:44:52 PM  1000         -     23955    0.00    0.00    0.00    0.00    0.00     2  |__http-nio-10800-
08:44:52 PM  1000         -     23956    0.00    0.00    0.00    0.00    0.00     1  |__http-nio-10800-
08:44:52 PM  1000         -     23958    0.00    0.00    0.00    0.00    0.00     2  |__http-nio-10800-
08:44:52 PM  1000         -     23963    0.00    0.00    0.00    0.00    0.00     0  |__http-nio-10800-
08:44:52 PM  1000         -     25601    0.00    0.00    0.00    0.00    0.00     3  |__Attach Listener

我们从其中选定scheduling-1这个线程,它的线程id是:20794

把它转为16进制:
[lhdop@blog ~]$ printf "%x\n" 20794
513a

然后查看jstack中输出的线程信息:

"scheduling-1" #25 prio=5 os_prio=0 cpu=1282.91ms elapsed=187201.74s tid=0x00007f45e17202c0 nid=0x513a waiting on condition  [0x00007f45624f4000]

可以看到nid就是操作系统给线程分配的id

四,jstack中的其他项的含义

以http-nio-10800-exec-1线程为例子:
"http-nio-10800-exec-1" #197 daemon prio=5 os_prio=0 cpu=215.99ms elapsed=162530.12s tid=0x00007f454c007230 nid=0x5519 waiting on condition  [0x00007f45620f1000]

1,"http-nio-10800-exec-1": 线程名字

2, #197 : 线程id 3, daemon : 是否守护线程,daemon表示是守护线程,daemon threads是低优先级的thread 4,prio=5: prio:java中的线程优先级,就是Thread中定义的值,取值范围: 1-10,默认值是5 5,os_prio: 对应的操作系统线程的优先级 6,cpu=215.99ms: 线程获得CPU的时间 7, elapsed=162530.12s :线程启动后经过的wall clock time 8,tid=0x00007f45e17202c0: 线程的内存地址  Java memory address of its internal Thread control structure

五,查看java的版本:

[lhdop@blog tools]$ java --version
java 15 2020-09-15
Java(TM) SE Runtime Environment (build 15+36-1562)
Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)

 

标签:15,0.00,jstack,util,concurrent,base,线程,java
来源: https://www.cnblogs.com/architectforest/p/16031609.html