如何在java中获取线程NID(本机ID)

时间:2015-09-15 06:25:39

标签: java multithreading thread-dump

  

“remoting-jmx client-thread-4”守护进程prio = 6 tid = 0x000000000f86b000 nid = 0x20e0>等待条件[0x000000000b82e000]     java.lang.Thread.State:TIMED_WAITING(停车)     在sun.misc.Unsafe.park(原生方法)      - 停车等待< 0x00000000ebd8bcc0> (a> java.util.concurrent.SynchronousQueue $ TransferStack)     at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)     at> java.util.concurrent.SynchronousQueue $ TransferStack.awaitFulfill(SynchronousQue> ue.java:460)     at> java.util.concurrent.SynchronousQueue $ TransferStack.transfer(SynchronousQueue.j> ava:359)     at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)     at> java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)       at> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)     at> java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)     在java.lang.Thread.run(Thread.java:745)

在这个线程转储中,我们有线程Nid。这个Nid如何从java代码中的一个线程中获取它。

1 个答案:

答案 0 :(得分:1)

以下是gist,其中显示了如果您可以在应用中包含project lombok lombok.jar和来自JDK的sa-jdi.jar来获取NID。