(待续)java查看线程ID、线程状态、是否持有锁信息、对象使用情况等,使用jdk自带的线程堆栈分析工具jstack和jmap

作者: admin 分类: JVM 发布时间: 2019-05-11 00:08  阅读: 40 views

在启动java项目或运行java项目的业务逻辑时,有时候需要看看对象创建了多少,线程对债的异常信息等。jstack和jmap是jdk自带的线程堆栈分析工具。每个线程堆中信息中,都可以查看到 线程ID、线程的状态、是否持有锁信息等。配合一些插件使用是很方便的。

jstack -h 使用帮助

chenhailongdeMacBook-Pro:~ chenhailong$ jstack -h
Usage:
    jstack [-l] <pid>
        (to connect to running process)
    jstack -F [-m] [-l] <pid>
        (to connect to a hung process)
    jstack [-m] [-l] <executable> <core>
        (to connect to a core file)
    jstack [-m] [-l] [server_id@]<remote server IP or hostname>
        (to connect to a remote debug server)

Options:
    -F  to force a thread dump. Use when jstack <pid> does not respond (process is hung)
    -m  to print both java and native frames (mixed mode)
    -l  long listing. Prints additional information about locks
    -h or -help to print this help message
以下是 jstack -l pid 打印出的信息。
chenhailongdeMacBook-Pro:bin chenhailong$ jstack -l 29106
2019-05-06 20:01:10
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.171-b11 mixed mode):

"Attach Listener" #163 daemon prio=9 os_prio=31 tid=0x00007f9800f05800 nid=0x4407 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"JavaScript indexing" #54 daemon prio=4 os_prio=31 tid=0x00007f9800319000 nid=0x11347 in Object.wait() [0x0000700004145000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:502)
	at org.eclipse.wst.jsdt.internal.core.search.processing.JobManager.run(JobManager.java:370)
	- locked <0x00000000c1a17d48> (a org.eclipse.wst.jsdt.internal.core.search.indexing.IndexManager)
	at java.lang.Thread.run(Thread.java:748)

   Locked ownable synchronizers:
	- None

"Worker-15" #48 prio=5 os_prio=31 tid=0x00007f980499a000 nid=0x1f403 in Object.wait() [0x0000700004042000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-14" #47 prio=5 os_prio=31 tid=0x00007f97ffcd8000 nid=0x1f503 in Object.wait() [0x0000700003f3f000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Thread-9" #46 daemon prio=2 os_prio=31 tid=0x00007f98060d8000 nid=0x1f603 waiting on condition [0x0000700003e3c000]
   java.lang.Thread.State: WAITING (parking)
	at sun.misc.Unsafe.park(Native Method)
	- parking to wait for  <0x00000000c6d00970> (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.LinkedBlockingDeque.takeFirst(LinkedBlockingDeque.java:492)
	at java.util.concurrent.LinkedBlockingDeque.take(LinkedBlockingDeque.java:680)
	at sun.nio.fs.AbstractWatchService.take(AbstractWatchService.java:118)
	at org.python.pydev.shared_core.path_watch.PathWatch$PollThread.run(PathWatch.java:120)

   Locked ownable synchronizers:
	- None

"Worker-13" #45 prio=5 os_prio=31 tid=0x00007f97fff9f000 nid=0x15f07 in Object.wait() [0x0000700003d39000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-12" #44 prio=5 os_prio=31 tid=0x00007f97fff6a000 nid=0x15d23 in Object.wait() [0x0000700003c36000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"process reaper" #41 daemon prio=10 os_prio=31 tid=0x00007f98047af000 nid=0x15b0b waiting on condition [0x0000700003b33000]
   java.lang.Thread.State: TIMED_WAITING (parking)
	at sun.misc.Unsafe.park(Native Method)
	- parking to wait for  <0x00000000c6480328> (a java.util.concurrent.SynchronousQueue$TransferStack)
	at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
	at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
	at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362)
	at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:941)
	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1073)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

   Locked ownable synchronizers:
	- None

"Worker-11" #40 prio=5 os_prio=31 tid=0x00007f97ffe30800 nid=0x1ff03 in Object.wait() [0x0000700003b08000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-10" #39 prio=5 os_prio=31 tid=0x00007f9800434000 nid=0x10403 in Object.wait() [0x0000700003a05000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-9" #38 prio=5 os_prio=31 tid=0x00007f9800563000 nid=0x10303 in Object.wait() [0x0000700003902000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-8" #37 prio=5 os_prio=31 tid=0x00007f97ff3fa800 nid=0x10103 in Object.wait() [0x00007000037ff000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-7" #36 prio=5 os_prio=31 tid=0x00007f9802d95000 nid=0xff03 in Object.wait() [0x00007000036fc000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-6" #35 prio=5 os_prio=31 tid=0x00007f980070f000 nid=0xfd03 in Object.wait() [0x00007000035f9000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-5" #34 prio=5 os_prio=31 tid=0x00007f97ff36b800 nid=0xfc03 in Object.wait() [0x00007000034f6000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-4" #33 prio=5 os_prio=31 tid=0x00007f9804710000 nid=0xfa03 in Object.wait() [0x00007000033f3000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-3" #32 prio=5 os_prio=31 tid=0x00007f98004f2800 nid=0xf803 in Object.wait() [0x00007000032f0000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-2" #31 prio=5 os_prio=31 tid=0x00007f97ff056800 nid=0xf603 in Object.wait() [0x00007000031ed000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Worker-1" #30 prio=5 os_prio=31 tid=0x00007f9804925000 nid=0xf50b in Object.wait() [0x00007000030ea000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"EventAdmin Async Event Dispatcher Thread" #29 daemon prio=6 os_prio=31 tid=0x00007f9804b79000 nid=0x1082b in Object.wait() [0x0000700002fe7000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:502)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.getNextEvent(EventManager.java:403)
	- locked <0x00000000c6482db0> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:339)

   Locked ownable synchronizers:
	- None

"Java indexing" #28 daemon prio=4 os_prio=31 tid=0x00007f9802d99800 nid=0xc51b in Object.wait() [0x0000700002ee4000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:502)
	at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:378)
	- locked <0x00000000c5180260> (a org.eclipse.jdt.internal.core.search.indexing.IndexManager)
	at java.lang.Thread.run(Thread.java:748)

   Locked ownable synchronizers:
	- None

"Bundle File Closer" #26 daemon prio=6 os_prio=31 tid=0x00007f9802f62000 nid=0xd507 in Object.wait() [0x0000700002b58000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:502)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.getNextEvent(EventManager.java:403)
	- locked <0x00000000c1c208e0> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:339)

   Locked ownable synchronizers:
	- None

"Worker-0" #25 prio=5 os_prio=31 tid=0x00007f9802d14800 nid=0xec0b in Object.wait() [0x0000700002de1000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:200)
	- locked <0x00000000c1b8b2d0> (a org.eclipse.core.internal.jobs.WorkerPool)
	at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

   Locked ownable synchronizers:
	- None

"Gogo shell" #21 prio=5 os_prio=31 tid=0x00007f97ffe60000 nid=0xd703 waiting on condition [0x0000700002c5b000]
   java.lang.Thread.State: WAITING (parking)
	at sun.misc.Unsafe.park(Native Method)
	- parking to wait for  <0x00000000c1b8b470> (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:1074)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

   Locked ownable synchronizers:
	- None

"EMF Reference Cleaner" #18 daemon prio=5 os_prio=31 tid=0x00007f9800567800 nid=0xd303 in Object.wait() [0x0000700002a55000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
	- locked <0x00000000c1b8b6f8> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
	at org.eclipse.emf.common.util.CommonUtil$1ReferenceClearingQueuePollingThread.run(CommonUtil.java:70)

   Locked ownable synchronizers:
	- None

"Worker-JM" #17 prio=5 os_prio=31 tid=0x00007f980052c800 nid=0xd103 in Object.wait() [0x0000700002952000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at org.eclipse.core.internal.jobs.InternalWorker.run(InternalWorker.java:62)
	- locked <0x00000000c1b8b8a8> (a java.util.ArrayList)

   Locked ownable synchronizers:
	- None

"SCR Component Actor" #15 daemon prio=5 os_prio=31 tid=0x00007f97ff27d000 nid=0x13e03 in Object.wait() [0x0000700002646000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x00000000c1b8bc00> (a java.util.LinkedList)
	at java.lang.Object.wait(Object.java:502)
	at org.apache.felix.scr.impl.ComponentActorThread.run(ComponentActorThread.java:83)
	- locked <0x00000000c1b8bc00> (a java.util.LinkedList)
	at java.lang.Thread.run(Thread.java:748)

   Locked ownable synchronizers:
	- None

"Start Level: Equinox Container: 53e10688-87a6-4996-93c8-7ea2ebdcf78f" #14 daemon prio=5 os_prio=31 tid=0x00007f97ff286800 nid=0x14503 in Object.wait() [0x0000700002543000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x00000000c1b8bc38> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
	at java.lang.Object.wait(Object.java:502)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.getNextEvent(EventManager.java:403)
	- locked <0x00000000c1b8bc38> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:339)

   Locked ownable synchronizers:
	- None

"Framework Event Dispatcher: Equinox Container: 53e10688-87a6-4996-93c8-7ea2ebdcf78f" #13 daemon prio=5 os_prio=31 tid=0x00007f97ffa9d800 nid=0x14717 in Object.wait() [0x0000700002440000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:502)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.getNextEvent(EventManager.java:403)
	- locked <0x00000000c1b8bdc0> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:339)

   Locked ownable synchronizers:
	- None

"Active Thread: Equinox Container: 53e10688-87a6-4996-93c8-7ea2ebdcf78f" #11 prio=5 os_prio=31 tid=0x00007f98002c7000 nid=0xb90b waiting on condition [0x000070000233d000]
   java.lang.Thread.State: TIMED_WAITING (parking)
	at sun.misc.Unsafe.park(Native Method)
	- parking to wait for  <0x00000000c1307838> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
	at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
	at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
	at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

   Locked ownable synchronizers:
	- None

"Service Thread" #9 daemon prio=9 os_prio=31 tid=0x00007f9800061800 nid=0x9603 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"C1 CompilerThread2" #8 daemon prio=9 os_prio=31 tid=0x00007f97ff8bd800 nid=0x9803 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"C2 CompilerThread1" #7 daemon prio=9 os_prio=31 tid=0x00007f980005e800 nid=0x9903 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"C2 CompilerThread0" #6 daemon prio=9 os_prio=31 tid=0x00007f980005e000 nid=0x9a03 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Signal Dispatcher" #5 daemon prio=9 os_prio=31 tid=0x00007f980005d000 nid=0x6a03 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Surrogate Locker Thread (Concurrent GC)" #4 daemon prio=9 os_prio=31 tid=0x00007f9800037000 nid=0x680b waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Finalizer" #3 daemon prio=8 os_prio=31 tid=0x00007f97ff8d4800 nid=0x6703 in Object.wait() [0x0000700001b25000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
	- locked <0x00000000c011e990> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:212)

   Locked ownable synchronizers:
	- None

"Reference Handler" #2 daemon prio=10 os_prio=31 tid=0x00007f9800050800 nid=0x6503 in Object.wait() [0x0000700001a22000]
   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 <0x00000000c0105b80> (a java.lang.ref.Reference$Lock)
	at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

   Locked ownable synchronizers:
	- None

"main" #1 prio=6 os_prio=31 tid=0x00007f980001b800 nid=0x307 runnable [0x00007ffee9b93000]
   java.lang.Thread.State: RUNNABLE
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend_bool(Native Method)
	at org.eclipse.swt.internal.cocoa.NSRunLoop.runMode(NSRunLoop.java:45)
	at org.eclipse.swt.widgets.Display.sleep(Display.java:4935)
	at org.eclipse.ui.application.WorkbenchAdvisor.eventLoopIdle(WorkbenchAdvisor.java:371)
	at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor.eventLoopIdle(IDEWorkbenchAdvisor.java:949)
	at org.eclipse.ui.internal.Workbench$1.eventLoopIdle(Workbench.java:485)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1178)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
	at org.eclipse.ui.internal.Workbench$$Lambda$85/1634001207.run(Unknown Source)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:566)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:155)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	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:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:661)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1476)

   Locked ownable synchronizers:
	- None

"VM Thread" os_prio=31 tid=0x00007f980004c000 nid=0x6403 runnable 
"Gang worker#0 (Parallel GC Threads)" os_prio=31 tid=0x00007f980001e800 nid=0xa907 runnable 
"Gang worker#1 (Parallel GC Threads)" os_prio=31 tid=0x00007f980001f000 nid=0x5703 runnable 
"Gang worker#2 (Parallel GC Threads)" os_prio=31 tid=0x00007f97ff832000 nid=0x5803 runnable 
"Gang worker#3 (Parallel GC Threads)" os_prio=31 tid=0x00007f97ff832800 nid=0x5a03 runnable 
"G1 Main Concurrent Mark GC Thread" os_prio=31 tid=0x00007f97ff00d000 nid=0x6203 runnable
"Gang worker#0 (G1 Parallel Marking Threads)" os_prio=31 tid=0x00007f97ff00d800 nid=0xa203 runnable 
"G1 Concurrent Refinement Thread#0" os_prio=31 tid=0x00007f980003b000 nid=0x6003 runnable 
"G1 Concurrent Refinement Thread#1" os_prio=31 tid=0x00007f97ff835800 nid=0x5f03 runnable 
"G1 Concurrent Refinement Thread#2" os_prio=31 tid=0x00007f97ff835000 nid=0xa503 runnable 
"G1 Concurrent Refinement Thread#3" os_prio=31 tid=0x00007f97ff834000 nid=0x5c03 runnable 
"G1 Concurrent Refinement Thread#4" os_prio=31 tid=0x00007f97ff833800 nid=0xa603 runnable 
"String Deduplication Thread" os_prio=31 tid=0x00007f97ff8b9000 nid=0xa103 runnable 
"VM Periodic Task Thread" os_prio=31 tid=0x00007f9800806800 nid=0x9503 waiting on condition 
JNI global references: 1884

 

jmap是一个多功能的命令。它可以生成 java 程序的 dump 文件, 也可以查看堆内对象示例的统计信息、查看 ClassLoader 的信息以及 finalizer 队列。

chenhailongdeMacBook-Pro:~ chenhailong$ jmap -h
Usage:
    jmap [option] <pid>
        (to connect to running process)
    jmap [option] <executable <core>
        (to connect to a core file)
    jmap [option] [server_id@]<remote server IP or hostname>
        (to connect to remote debug server)

where <option> is one of:
    <none>               to print same info as Solaris pmap
    -heap                to print java heap summary
    -histo[:live]        to print histogram of java object heap; if the "live"
                         suboption is specified, only count live objects
    -clstats             to print class loader statistics
    -finalizerinfo       to print information on objects awaiting finalization
    -dump:<dump-options> to dump java heap in hprof binary format
                         dump-options:
                           live         dump only live objects; if not specified,
                                        all objects in the heap are dumped.
                           format=b     binary format
                           file=<file>  dump heap to <file>
                         Example: jmap -dump:live,format=b,file=heap.bin <pid>
    -F                   force. Use with -dump:<dump-options> <pid> or -histo
                         to force a heap dump or histogram when <pid> does not
                         respond. The "live" suboption is not supported
                         in this mode.
    -h | -help           to print this help message
    -J<flag>             to pass <flag> directly to the runtime system

我这里本地一运行 jmap命令就会关掉相关进程, 网上查询可能是jdk版本问题,待处理好后,整理份关于jstack\jmap的实战记录

查看官方解释https://bugs.java.com/bugdatabase/view_bug.do?bug_id=7110428

 

待续…  等有空及合适的处理场景


   原创文章,转载请标明本文链接: (待续)java查看线程ID、线程状态、是否持有锁信息、对象使用情况等,使用jdk自带的线程堆栈分析工具jstack和jmap

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注