问题描述
我想通过java代码生成线程转储,我尝试使用ThreadMXBean但是我没有以正确的格式获得线程转储,因为我们正在使用 jstack 命令。请任何人提供一些帮助..是他们的任何其他方式来获取线程转储...使用任何其他API ..我想要的线程转储的格式是 -
2015-08-06 05:51:15
全线程转储Java HotSpot(TM)64位服务器VM(24.51-b03混合模式):
Attach Listener守护进程prio = 10 tid = 0x00007fdab805d800 nid = 0x7a36等待条件[0x0000000000000000]
java.lang.Thread.State:RUNNABLE
ajp-mco / 127.168.121.120:8170-220守护进程prio = 10 tid = 0x00007fdaa056d000 nid = 0x7961 runnable [0x00007fda8bb7a000]
java.lang.Thread.State:在java.net.SocketInputStream.socketRead0(本机方法)上运行
java.net.SocketInputStream.read上的
(SocketInputStream.java:152)java.net.SocketInputStream.read上的
(SocketInputStream .java:122)
at org.apache.coyote.ajp.AjpProcessor.read(AjpProcessor.java:1114)
at org.apache.coyote.ajp.AjpProcessor.readMessage(AjpProcessor.java:1196 )org.apache.coyote.ajp上的
。 AjpProcessor.process(AjpProcessor.java:436)
at org.apache.coyote.ajp.AjpProtocol $ AjpConnectionHandler.process(AjpProtocol.java:420)
at org.apache.tomcat.util.net。 JIoEndpoint $ Worker.run(JIoEndpoint.java:920)
at java.lang.Thread.run(Thread.java:744)
尝试 ManagementFactory.getThreadMXBean()。dumpAllThreads(true,true)
使用
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
ThreadInfo [] infos = bean.dumpAllThreads(true,true);
for(ThreadInfo info:infos){
System.out.println(info);
}
或者你可以破解方式并实际调用 jstack
通过 Runtime.getRuntime.exec()
:
String pid = ManagementFactory.getRuntimeMXBean()。getName()。replaceAll([^ \\d。],);
InputStream in = Runtime.getRuntime()。exec(PATH_TO_JSTACK ++ pid).getInputStream();
System.out.println(IOUtils.toString(InputStream));
以下是使用
ThreadMXBean
: pool-1-thread-4 Id = 14 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
at sun.misc.Unsafe.park(Native Method)
- 等待java.util.concurrent.locks.AbstractQueuedSynchronizer $ ConditionObject @ 2d98a335
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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java .util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
at java .lang.Thread.run(Thread.java:745)
pool-1-thread-3Id = 13等待java.util.concurrent.locks.AbstractQueuedSynchronizer $ ConditionObject @ 2d98a335
at sun.misc.Unsafe.park(Native Method)
- 在java.util.concurrent.locks上等待java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer $ ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
pool-1-thread-2Id = 12在java.util.concurr上等待ent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
at sun.misc.Unsafe.park(Native Method)
- 等待java.util.concurrent.locks.AbstractQueuedSynchronizer $ConditionObject@2d98a335
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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
pool-1-thread-1Id = 11等待java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
at sun.misc.Unsafe.park(原住民M. ethod)
- 等待java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util。 concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run( ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Monitor Ctrl-BreakId = 10 RUNNABLE(原生)java.net.DualStackPlainSocketImpl.accept0(本机方法)
java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
java.net.AbstractPlainSocketImpl.ac cept(AbstractPlainSocketImpl.java:409)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
- 在java.net.ServerSocket上锁定java.net.SocksSocketImpl@16b98e56
.implAccept(ServerSocket.java:545)
at java.net.ServerSocket.accept(ServerSocket.java:513)
at com.intellij.rt.execution.application.AppMain $ 1.run(AppMain。 java:90)
at java.lang.Thread.run(Thread.java:745)
Attach ListenerId = 5 RUNNABLE
Signal DispatcherId = 4 RUNNABLE
FinalizerId = 3等待java.lang.ref.ReferenceQueue$Lock@7ef20235
at java .lang.Object.wait(Native Method)
- 等待java.lang.ref.ReferenceQueue$Lock@7ef20235
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
at java.lang.ref.Finalizer $ FinalizerThread.run(Finalizer.java:209)
参考处理程序Id = 2等待on java.lang.ref.Reference$Lock@27d6c5e0
at java.lang.Object.wait(Native Method)
- wait on java.lang.ref.Reference$Lock@27d6c5e0
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference $ ReferenceHandler.run(Reference.java:157)
mainId = 1 RUNNABLE
at sun.management.ThreadImpl.dumpThreads0(Native Method)
at sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:446)
at Playground.main (Playground.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect .DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main (AppMain.java:144)
jstack
(通过控制台或通过 R untime.getRuntime()。exec()
):
完全线程转储Java HotSpot(TM) 64位服务器VM(25.65-b01混合模式):
DestroyJavaVM#15 prio = 5 os_prio = 0 tid = 0x00000000008bd800 nid = 0x41c等待条件[0x0000000000000000]
java。 lang.Thread.State:RUNNABLE
pool-1-thread-4#14 prio = 5 os_prio = 0 tid = 0x0000000016660800 nid = 0x166c等待条件[0x0000000016dff000]
java。 lang.Thread.State:等待(停车)
在sun.misc.Unsafe.park(原生方法)
- 停车等待< 0x00000000eb360088> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor。 java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
pool-1-thread-3#13 prio = 5 os_prio = 0 tid = 0x0000000016660000 nid = 0x1e34等待condition [0x0000000016cff000]
java.lang.Thread.State:WAITING(停车)
at sun.misc.Unsafe.park(原生方法)
- 停车等待< 0x00000000eb36 0088> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor。 java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
pool-1-thread-2#12 prio = 5 os_prio = 0 tid = 0x000000001665f000 nid = 0x148等待condition [0x0000000016bff000]
java.lang.Thread.State:WAITING(停车)
at sun.misc.Unsafe.park(原生方法)
- 停车等待< 0x00000000eb360 088> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor。 java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
pool-1-thread-1#11 prio = 5 os_prio = 0 tid = 0x000000001665b800 nid = 0xdf0等待condition [0x0000000016afe000]
java.lang.Thread.State:WAITING(停车)
at sun.misc.Unsafe.park(原生方法)
- 停车等待< 0x00000000eb360 088> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor。 java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Monitor Ctrl-Break#10 daemon prio = 5 os_prio = 0 tid = 0x000000001641d000 nid = 0x2038 runnable [0x00000000169fe000]
java.lang.Thread.State:java.net.DualStackPlainSocketImpl.accept0(本机方法)的RUNNABLE
java.net.DualStackPlainSocke上的
tImpl.socketAccept(DualStackPlainSocketImpl.java:131)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
- 已锁定< 0x00000000eb39db18> (java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(ServerSocket.java:545)
at java.net.ServerSocket.accept(ServerSocket.java:513)
at com.intellij.rt.execution.application.AppMain $ 1.run(AppMain.java:90)
at java.lang.Thread.run(Thread.java:745)
服务线程#9 daemon prio = 9 os_prio = 0 tid = 0x0000000014a1e000 nid = 0x360 runnable [0x0000000000000000]
java.lang.Thread.State:RUNNABLE
C1 CompilerThread2#8守护进程prio = 9 os_prio = 2 tid = 0x00000000149c3800 nid = 0x89c等待条件[0x0000000000000000]
java.lang.Thread.State:RUNNABLE
C2 CompilerThread1#7 daemon prio = 9 os_prio = 2 tid = 0x00000000149c0800 nid = 0x2048等待条件[0x0000000000000000]
java.lang.Thread.State:RUNNABLE
C2 CompilerThread0#6 daemon prio = 9 os_prio = 2 tid = 0x00000000149bd800 nid = 0x1aa0等待条件[0x0000000000000000]
java.lang.Thread.State:RUNNABLE
附加侦听器#5守护程序prio = 5 os_prio = 2 tid = 0x00000000149bc000 nid = 0x108c等待条件[0x0000000000000000]
java.lang.Thread.State:RUNNABLE
Signal Dispatcher#4 daemon prio = 9 os_prio = 2 tid = 0x00000000149bb000 nid = 0x15a4 runnable [0x0000000000000000]
java.lang.Thread.State:RUNNABLE
Finalizer#3守护进程对象。中的prio = 8 os_prio = 1 tid = 0x00000000023b1000 nid = 0x182c [0x0000000015d1e000]
java.lang.Thread.State:WAITING(在对象监视器上)
at java.lang.Object。等待(本机方法)
- 等待< 0x00000000eb2070b8> (java.lang.ref.ReferenceQueue $ Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
- locked< 0x00000000eb2070b8> (java.lang.ref.ReferenceQueue $ Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
at java.lang.ref.Finalizer $ FinalizerThread.run( Finalizer.java:209)
参考处理程序#2守护程序prio = 10 os_prio = 2 tid = 0x00000000023ae000 nid = 0x21f4 in Object.wait()[0x0000000015c1f000]
java.lang。 Thread.State:WAITING(在对象监视器上)
at java.lang.Object.wait(Native Method)
- wait on< 0x00000000eb206af8> (java.lang.ref.Reference $ Lock)
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference $ ReferenceHandler.run(Reference。 java:157)
- 已锁定< 0x00000000eb206af8> (java.lang.ref.Reference $ Lock)
VM Threados_prio = 2 tid = 0x0000000014987000 nid = 0x17cc runnable
GC任务线程#0(ParallelGC) )os_prio = 0 tid = 0x00000000022d7800 nid = 0x2208 runnable
GC任务线程#1(ParallelGC)os_prio = 0 tid = 0x00000000022d9000 nid = 0x24c4 runnable
GC任务线程#2(ParallelGC)os_prio = 0 tid = 0x00000000022da800 nid = 0x7b0 runnable
GC任务线程#3(ParallelGC)os_prio = 0 tid = 0x00000000022dc000 nid = 0x2650 runnable
VM Periodic Task Threados_prio = 2 tid = 0x000000001634a800 nid = 0x271c等待条件
JNI全球参考:321
I want to generate thread dump through java code, I tried using ThreadMXBean for this but I am not getting the thread dump in the proper format as we are getting using jstack command. Please can any one provide some help..is their any other way to get thread dump... using any other API.. The format of thread dump that i want is -
2015-08-06 05:51:15
Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode):
"Attach Listener" daemon prio=10 tid=0x00007fdab805d800 nid=0x7a36 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"ajp-mco/127.168.121.120:8170-220" daemon prio=10 tid=0x00007fdaa056d000 nid=0x7961 runnable [0x00007fda8bb7a000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at org.apache.coyote.ajp.AjpProcessor.read(AjpProcessor.java:1114)
at org.apache.coyote.ajp.AjpProcessor.readMessage(AjpProcessor.java:1196)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436)
at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:420)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)
at java.lang.Thread.run(Thread.java:744)
Try ManagementFactory.getThreadMXBean().dumpAllThreads(true, true)
using something like
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
ThreadInfo[] infos = bean.dumpAllThreads(true, true);
for (ThreadInfo info : infos) {
System.out.println(info);
}
Alternatively you can hack your way around and actually call jstack
through Runtime.getRuntime.exec()
:
String pid = ManagementFactory.getRuntimeMXBean().getName().replaceAll("[^\\d.]", "");
InputStream in = Runtime.getRuntime().exec(PATH_TO_JSTACK + " " + pid).getInputStream();
System.out.println(IOUtils.toString(InputStream));
Here's the output for a sample program using
ThreadMXBean
:
"pool-1-thread-4" Id=14 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
at sun.misc.Unsafe.park(Native Method)
- waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"pool-1-thread-3" Id=13 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
at sun.misc.Unsafe.park(Native Method)
- waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"pool-1-thread-2" Id=12 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
at sun.misc.Unsafe.park(Native Method)
- waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"pool-1-thread-1" Id=11 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
at sun.misc.Unsafe.park(Native Method)
- waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2d98a335
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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"Monitor Ctrl-Break" Id=10 RUNNABLE (in native)
at java.net.DualStackPlainSocketImpl.accept0(Native Method)
at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
- locked java.net.SocksSocketImpl@16b98e56
at java.net.ServerSocket.implAccept(ServerSocket.java:545)
at java.net.ServerSocket.accept(ServerSocket.java:513)
at com.intellij.rt.execution.application.AppMain$1.run(AppMain.java:90)
at java.lang.Thread.run(Thread.java:745)
"Attach Listener" Id=5 RUNNABLE
"Signal Dispatcher" Id=4 RUNNABLE
"Finalizer" Id=3 WAITING on java.lang.ref.ReferenceQueue$Lock@7ef20235
at java.lang.Object.wait(Native Method)
- waiting on java.lang.ref.ReferenceQueue$Lock@7ef20235
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)
"Reference Handler" Id=2 WAITING on java.lang.ref.Reference$Lock@27d6c5e0
at java.lang.Object.wait(Native Method)
- waiting on java.lang.ref.Reference$Lock@27d6c5e0
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:157)
"main" Id=1 RUNNABLE
at sun.management.ThreadImpl.dumpThreads0(Native Method)
at sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:446)
at Playground.main(Playground.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
jstack
(thorugh the console or through Runtime.getRuntime().exec()
):
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.65-b01 mixed mode):
"DestroyJavaVM" #15 prio=5 os_prio=0 tid=0x00000000008bd800 nid=0x41c waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"pool-1-thread-4" #14 prio=5 os_prio=0 tid=0x0000000016660800 nid=0x166c waiting on condition [0x0000000016dff000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000eb360088> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"pool-1-thread-3" #13 prio=5 os_prio=0 tid=0x0000000016660000 nid=0x1e34 waiting on condition [0x0000000016cff000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000eb360088> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"pool-1-thread-2" #12 prio=5 os_prio=0 tid=0x000000001665f000 nid=0x148 waiting on condition [0x0000000016bff000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000eb360088> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"pool-1-thread-1" #11 prio=5 os_prio=0 tid=0x000000001665b800 nid=0xdf0 waiting on condition [0x0000000016afe000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000eb360088> (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.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"Monitor Ctrl-Break" #10 daemon prio=5 os_prio=0 tid=0x000000001641d000 nid=0x2038 runnable [0x00000000169fe000]
java.lang.Thread.State: RUNNABLE
at java.net.DualStackPlainSocketImpl.accept0(Native Method)
at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
- locked <0x00000000eb39db18> (a java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(ServerSocket.java:545)
at java.net.ServerSocket.accept(ServerSocket.java:513)
at com.intellij.rt.execution.application.AppMain$1.run(AppMain.java:90)
at java.lang.Thread.run(Thread.java:745)
"Service Thread" #9 daemon prio=9 os_prio=0 tid=0x0000000014a1e000 nid=0x360 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C1 CompilerThread2" #8 daemon prio=9 os_prio=2 tid=0x00000000149c3800 nid=0x89c waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread1" #7 daemon prio=9 os_prio=2 tid=0x00000000149c0800 nid=0x2048 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread0" #6 daemon prio=9 os_prio=2 tid=0x00000000149bd800 nid=0x1aa0 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Attach Listener" #5 daemon prio=5 os_prio=2 tid=0x00000000149bc000 nid=0x108c waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Signal Dispatcher" #4 daemon prio=9 os_prio=2 tid=0x00000000149bb000 nid=0x15a4 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x00000000023b1000 nid=0x182c in Object.wait() [0x0000000015d1e000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000eb2070b8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
- locked <0x00000000eb2070b8> (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)
"Reference Handler" #2 daemon prio=10 os_prio=2 tid=0x00000000023ae000 nid=0x21f4 in Object.wait() [0x0000000015c1f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000eb206af8> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:157)
- locked <0x00000000eb206af8> (a java.lang.ref.Reference$Lock)
"VM Thread" os_prio=2 tid=0x0000000014987000 nid=0x17cc runnable
"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00000000022d7800 nid=0x2208 runnable
"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00000000022d9000 nid=0x24c4 runnable
"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00000000022da800 nid=0x7b0 runnable
"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00000000022dc000 nid=0x2650 runnable
"VM Periodic Task Thread" os_prio=2 tid=0x000000001634a800 nid=0x271c waiting on condition
JNI global references: 321
这篇关于如何使用JAVA代码以编程方式捕获线程转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!