测试监视器锁的等待/通知机制

贴代码啦

  1 public class App {
  2 
  3     final static Object lock = new Object();
  4 
  5     public static void main(String[] args) throws InterruptedException {
  6         testWait();
  7         testTimedWait();
  8     }
  9 
 10     /**
 11      * 当进入NotifyThread,10s内dump,可以看到WaitThread是WAITING状态;<br/>
 12      * 当打印"start to notify", 10s内dump,可以看到WaitThread是BLOCKED状态。<br/>
 13      * 说明notify唤醒了WaitThread,使其由等待队列迁移到同步队列。
 14      *
 15      * @throws InterruptedException
 16      */
 17     private static void testWait() throws InterruptedException {
 18         Thread waitThread = new Thread(new Runnable() {
 19             public void run() {
 20                 synchronized (lock) {
 21                     try {
 22                         lock.wait();
 23                     } catch (InterruptedException e) {
 24                         e.printStackTrace();
 25                     }
 26                 }
 27             }
 28         }, "WaitThread");
 29 
 30         Thread notifyThread = new Thread(new Runnable() {
 31             public void run() {
 32                 synchronized (lock) {
 33                     System.out.println("enter notify thread");
 34                     try {
 35                         Thread.sleep(10000L);
 36                     } catch (InterruptedException e) {
 37                         e.printStackTrace();
 38                     }
 39                     System.out.println("start to notify");
 40                     lock.notify();
 41                     try {
 42                         Thread.sleep(10000L);
 43                     } catch (InterruptedException e) {
 44                         e.printStackTrace();
 45                     }
 46                 }
 47             }
 48         }, "NotifyThread");
 49 
 50         waitThread.start();
 51         Thread.sleep(1000L);
 52         notifyThread.start();
 53     }
 54 
 55     /**
 56      * 当进入NotifyThread,10s内dump,可以看到WaitThread是WAITING状态;<br/>
 57      * 10s-30s之间dump,可以看到WaitThread是BLOCKED状态。<br/>
 58      * 说明WaitThread未等NotifyThread唤醒,自己超时唤醒了。<br/>
 59      * 在打印"start to notify"之后再次dump,WaitThread仍然是BLOCKED.
 60      *
 61      * @throws InterruptedException
 62      */
 63     private static void testTimedWait() throws InterruptedException {
 64         Thread waitThread = new Thread(new Runnable() {
 65             public void run() {
 66                 synchronized (lock) {
 67                     try {
 68                         lock.wait(10000L);
 69                     } catch (InterruptedException e) {
 70                         e.printStackTrace();
 71                     }
 72                 }
 73             }
 74         }, "WaitThread");
 75 
 76         Thread notifyThread = new Thread(new Runnable() {
 77             public void run() {
 78                 synchronized (lock) {
 79                     System.out.println("enter notify thread");
 80                     try {
 81                         Thread.sleep(30000L);
 82                     } catch (InterruptedException e) {
 83                         e.printStackTrace();
 84                     }
 85                     System.out.println("start to notify");
 86                     lock.notify();
 87                     try {
 88                         Thread.sleep(10000L);
 89                     } catch (InterruptedException e) {
 90                         e.printStackTrace();
 91                     }
 92                 }
 93             }
 94         }, "NotifyThread");
 95 
 96         waitThread.start();
 97         Thread.sleep(1000L);
 98         notifyThread.start();
 99     }
100 }

 

按照代码的注释操作,控制台的输出如下,观察WaitThread的变化。

testWait():

enter notify thread
2018-04-05 17:51:13
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode):

"DestroyJavaVM" prio=6 tid=0x000000000262e000 nid=0x2d88 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"NotifyThread" prio=6 tid=0x000000000da27800 nid=0x15dc waiting on condition [0x000000000e92e000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at com.smart.dao.App$2.run(App.java:42)
    - locked <0x00000007d6009628> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"WaitThread" prio=6 tid=0x000000000da3d000 nid=0x2ce0 in Object.wait() [0x000000000e72f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d6009628> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:503)
    at com.smart.dao.App$1.run(App.java:28)
    - locked <0x00000007d6009628> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"Service Thread" daemon prio=6 tid=0x000000000da3c000 nid=0x2d2c runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x000000000da3b000 nid=0x2ae0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x000000000da38000 nid=0xa74 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Monitor Ctrl-Break" daemon prio=6 tid=0x000000000d9ef000 nid=0x2db0 runnable [0x000000000dece000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
    - locked <0x00000007d60cea18> (a java.io.InputStreamReader)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.fill(BufferedReader.java:154)
    at java.io.BufferedReader.readLine(BufferedReader.java:317)
    - locked <0x00000007d60cea18> (a java.io.InputStreamReader)
    at java.io.BufferedReader.readLine(BufferedReader.java:382)
    at com.intellij.rt.execution.application.AppMainV2$1.run(AppMainV2.java:64)

"Attach Listener" daemon prio=10 tid=0x000000000bd1e800 nid=0x2950 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x000000000bd17800 nid=0x2ff0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x0000000002848800 nid=0x2d30 in Object.wait() [0x000000000d00e000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)

"Reference Handler" daemon prio=10 tid=0x000000000bc72800 nid=0x29b4 in Object.wait() [0x000000000cf0e000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x000000000bc71800 nid=0x2ea4 runnable 

"GC task thread#0 (ParallelGC)" prio=6 tid=0x0000000002795000 nid=0x2de8 runnable 

"GC task thread#1 (ParallelGC)" prio=6 tid=0x0000000002797000 nid=0x2d9c runnable 

"GC task thread#2 (ParallelGC)" prio=6 tid=0x0000000002798800 nid=0x245c runnable 

"GC task thread#3 (ParallelGC)" prio=6 tid=0x000000000279a800 nid=0x2b64 runnable 

"VM Periodic Task Thread" prio=10 tid=0x000000000bd5f000 nid=0x29e0 waiting on condition 

JNI global references: 135

Heap
 PSYoungGen      total 37696K, used 3878K [0x00000007d5eb0000, 0x00000007d88c0000, 0x0000000800000000)
  eden space 32320K, 12% used [0x00000007d5eb0000,0x00000007d6279bd8,0x00000007d7e40000)
  from space 5376K, 0% used [0x00000007d8380000,0x00000007d8380000,0x00000007d88c0000)
  to   space 5376K, 0% used [0x00000007d7e40000,0x00000007d7e40000,0x00000007d8380000)
 ParOldGen       total 86144K, used 0K [0x0000000781c00000, 0x0000000787020000, 0x00000007d5eb0000)
  object space 86144K, 0% used [0x0000000781c00000,0x0000000781c00000,0x0000000787020000)
 PSPermGen       total 21248K, used 3277K [0x000000077ca00000, 0x000000077dec0000, 0x0000000781c00000)
  object space 21248K, 15% used [0x000000077ca00000,0x000000077cd33480,0x000000077dec0000)

start to notify
2018-04-05 17:51:25
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode):

"DestroyJavaVM" prio=6 tid=0x000000000262e000 nid=0x2d88 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"NotifyThread" prio=6 tid=0x000000000da27800 nid=0x15dc waiting on condition [0x000000000e92e000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at com.smart.dao.App$2.run(App.java:49)
    - locked <0x00000007d6009628> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"WaitThread" prio=6 tid=0x000000000da3d000 nid=0x2ce0 in Object.wait() [0x000000000e72f000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d6009628> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:503)
    at com.smart.dao.App$1.run(App.java:28)
    - locked <0x00000007d6009628> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"Service Thread" daemon prio=6 tid=0x000000000da3c000 nid=0x2d2c runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x000000000da3b000 nid=0x2ae0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x000000000da38000 nid=0xa74 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Monitor Ctrl-Break" daemon prio=6 tid=0x000000000d9ef000 nid=0x2db0 runnable [0x000000000decf000]
   java.lang.Thread.State: RUNNABLE
    at com.intellij.rt.execution.application.AppMainV2.triggerControlBreak(Native Method)
    at com.intellij.rt.execution.application.AppMainV2.access$000(AppMainV2.java:32)
    at com.intellij.rt.execution.application.AppMainV2$1.run(AppMainV2.java:70)

"Attach Listener" daemon prio=10 tid=0x000000000bd1e800 nid=0x2950 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x000000000bd17800 nid=0x2ff0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x0000000002848800 nid=0x2d30 in Object.wait() [0x000000000d00e000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)

"Reference Handler" daemon prio=10 tid=0x000000000bc72800 nid=0x29b4 in Object.wait() [0x000000000cf0e000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x000000000bc71800 nid=0x2ea4 runnable 

"GC task thread#0 (ParallelGC)" prio=6 tid=0x0000000002795000 nid=0x2de8 runnable 

"GC task thread#1 (ParallelGC)" prio=6 tid=0x0000000002797000 nid=0x2d9c runnable 

"GC task thread#2 (ParallelGC)" prio=6 tid=0x0000000002798800 nid=0x245c runnable 

"GC task thread#3 (ParallelGC)" prio=6 tid=0x000000000279a800 nid=0x2b64 runnable 

"VM Periodic Task Thread" prio=10 tid=0x000000000bd5f000 nid=0x29e0 waiting on condition 

JNI global references: 135

Heap
 PSYoungGen      total 37696K, used 3878K [0x00000007d5eb0000, 0x00000007d88c0000, 0x0000000800000000)
  eden space 32320K, 12% used [0x00000007d5eb0000,0x00000007d6279bd8,0x00000007d7e40000)
  from space 5376K, 0% used [0x00000007d8380000,0x00000007d8380000,0x00000007d88c0000)
  to   space 5376K, 0% used [0x00000007d7e40000,0x00000007d7e40000,0x00000007d8380000)
 ParOldGen       total 86144K, used 0K [0x0000000781c00000, 0x0000000787020000, 0x00000007d5eb0000)
  object space 86144K, 0% used [0x0000000781c00000,0x0000000781c00000,0x0000000787020000)
 PSPermGen       total 21248K, used 3277K [0x000000077ca00000, 0x000000077dec0000, 0x0000000781c00000)
  object space 21248K, 15% used [0x000000077ca00000,0x000000077cd33480,0x000000077dec0000)


Process finished with exit code 0

 

testTimedWait():

enter notify thread
2018-04-05 17:56:00
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode):

"DestroyJavaVM" prio=6 tid=0x000000000264e000 nid=0x2c80 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"NotifyThread" prio=6 tid=0x000000000dae6800 nid=0x2ee8 waiting on condition [0x000000000e70f000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at com.smart.dao.App$2.run(App.java:41)
    - locked <0x00000007d600a1e0> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"WaitThread" prio=6 tid=0x000000000dc24800 nid=0x2cb4 in Object.wait() [0x000000000e57f000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d600a1e0> (a java.lang.Object)
    at com.smart.dao.App$1.run(App.java:27)
    - locked <0x00000007d600a1e0> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"Service Thread" daemon prio=6 tid=0x000000000dafc000 nid=0x1568 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x000000000dafb000 nid=0x2e1c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x000000000daf8000 nid=0x2d00 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Monitor Ctrl-Break" daemon prio=6 tid=0x000000000daaf000 nid=0x2eec runnable [0x000000000d5bf000]
   java.lang.Thread.State: RUNNABLE
    at com.intellij.rt.execution.application.AppMainV2.triggerControlBreak(Native Method)
    at com.intellij.rt.execution.application.AppMainV2.access$000(AppMainV2.java:32)
    at com.intellij.rt.execution.application.AppMainV2$1.run(AppMainV2.java:70)

"Attach Listener" daemon prio=10 tid=0x000000000beee800 nid=0x2c54 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x000000000bee7800 nid=0x2fd0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x0000000002608800 nid=0x2fd8 in Object.wait() [0x000000000d1bf000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)

"Reference Handler" daemon prio=10 tid=0x0000000002601800 nid=0x2e30 in Object.wait() [0x000000000d06f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x000000000be41800 nid=0x2850 runnable 

"GC task thread#0 (ParallelGC)" prio=6 tid=0x0000000002555000 nid=0x24c4 runnable 

"GC task thread#1 (ParallelGC)" prio=6 tid=0x0000000002557000 nid=0x2d28 runnable 

"GC task thread#2 (ParallelGC)" prio=6 tid=0x0000000002558800 nid=0x1a58 runnable 

"GC task thread#3 (ParallelGC)" prio=6 tid=0x000000000255a800 nid=0x2eb8 runnable 

"VM Periodic Task Thread" prio=10 tid=0x000000000bf2f000 nid=0x2940 waiting on condition 

JNI global references: 135

Heap
 PSYoungGen      total 37696K, used 3878K [0x00000007d5eb0000, 0x00000007d88c0000, 0x0000000800000000)
  eden space 32320K, 12% used [0x00000007d5eb0000,0x00000007d6279bd8,0x00000007d7e40000)
  from space 5376K, 0% used [0x00000007d8380000,0x00000007d8380000,0x00000007d88c0000)
  to   space 5376K, 0% used [0x00000007d7e40000,0x00000007d7e40000,0x00000007d8380000)
 ParOldGen       total 86144K, used 0K [0x0000000781c00000, 0x0000000787020000, 0x00000007d5eb0000)
  object space 86144K, 0% used [0x0000000781c00000,0x0000000781c00000,0x0000000787020000)
 PSPermGen       total 21248K, used 3277K [0x000000077ca00000, 0x000000077dec0000, 0x0000000781c00000)
  object space 21248K, 15% used [0x000000077ca00000,0x000000077cd335b0,0x000000077dec0000)

2018-04-05 17:56:18
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode):

"DestroyJavaVM" prio=6 tid=0x000000000264e000 nid=0x2c80 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"NotifyThread" prio=6 tid=0x000000000dae6800 nid=0x2ee8 waiting on condition [0x000000000e70f000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at com.smart.dao.App$2.run(App.java:41)
    - locked <0x00000007d600a1e0> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"WaitThread" prio=6 tid=0x000000000dc24800 nid=0x2cb4 waiting for monitor entry [0x000000000e57f000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d600a1e0> (a java.lang.Object)
    at com.smart.dao.App$1.run(App.java:27)
    - locked <0x00000007d600a1e0> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"Service Thread" daemon prio=6 tid=0x000000000dafc000 nid=0x1568 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x000000000dafb000 nid=0x2e1c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x000000000daf8000 nid=0x2d00 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Monitor Ctrl-Break" daemon prio=6 tid=0x000000000daaf000 nid=0x2eec runnable [0x000000000d5bf000]
   java.lang.Thread.State: RUNNABLE
    at com.intellij.rt.execution.application.AppMainV2.triggerControlBreak(Native Method)
    at com.intellij.rt.execution.application.AppMainV2.access$000(AppMainV2.java:32)
    at com.intellij.rt.execution.application.AppMainV2$1.run(AppMainV2.java:70)

"Attach Listener" daemon prio=10 tid=0x000000000beee800 nid=0x2c54 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x000000000bee7800 nid=0x2fd0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x0000000002608800 nid=0x2fd8 in Object.wait() [0x000000000d1bf000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)

"Reference Handler" daemon prio=10 tid=0x0000000002601800 nid=0x2e30 in Object.wait() [0x000000000d06f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x000000000be41800 nid=0x2850 runnable 

"GC task thread#0 (ParallelGC)" prio=6 tid=0x0000000002555000 nid=0x24c4 runnable 

"GC task thread#1 (ParallelGC)" prio=6 tid=0x0000000002557000 nid=0x2d28 runnable 

"GC task thread#2 (ParallelGC)" prio=6 tid=0x0000000002558800 nid=0x1a58 runnable 

"GC task thread#3 (ParallelGC)" prio=6 tid=0x000000000255a800 nid=0x2eb8 runnable 

"VM Periodic Task Thread" prio=10 tid=0x000000000bf2f000 nid=0x2940 waiting on condition 

JNI global references: 135

Heap
 PSYoungGen      total 37696K, used 3878K [0x00000007d5eb0000, 0x00000007d88c0000, 0x0000000800000000)
  eden space 32320K, 12% used [0x00000007d5eb0000,0x00000007d6279bd8,0x00000007d7e40000)
  from space 5376K, 0% used [0x00000007d8380000,0x00000007d8380000,0x00000007d88c0000)
  to   space 5376K, 0% used [0x00000007d7e40000,0x00000007d7e40000,0x00000007d8380000)
 ParOldGen       total 86144K, used 0K [0x0000000781c00000, 0x0000000787020000, 0x00000007d5eb0000)
  object space 86144K, 0% used [0x0000000781c00000,0x0000000781c00000,0x0000000787020000)
 PSPermGen       total 21248K, used 3277K [0x000000077ca00000, 0x000000077dec0000, 0x0000000781c00000)
  object space 21248K, 15% used [0x000000077ca00000,0x000000077cd335b0,0x000000077dec0000)

start to notify
2018-04-05 17:56:32
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode):

"DestroyJavaVM" prio=6 tid=0x000000000264e000 nid=0x2c80 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"NotifyThread" prio=6 tid=0x000000000dae6800 nid=0x2ee8 waiting on condition [0x000000000e70f000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at com.smart.dao.App$2.run(App.java:48)
    - locked <0x00000007d600a1e0> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"WaitThread" prio=6 tid=0x000000000dc24800 nid=0x2cb4 waiting for monitor entry [0x000000000e57f000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d600a1e0> (a java.lang.Object)
    at com.smart.dao.App$1.run(App.java:27)
    - locked <0x00000007d600a1e0> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:722)

"Service Thread" daemon prio=6 tid=0x000000000dafc000 nid=0x1568 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x000000000dafb000 nid=0x2e1c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x000000000daf8000 nid=0x2d00 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Monitor Ctrl-Break" daemon prio=6 tid=0x000000000daaf000 nid=0x2eec runnable [0x000000000d5bf000]
   java.lang.Thread.State: RUNNABLE
    at com.intellij.rt.execution.application.AppMainV2.triggerControlBreak(Native Method)
    at com.intellij.rt.execution.application.AppMainV2.access$000(AppMainV2.java:32)
    at com.intellij.rt.execution.application.AppMainV2$1.run(AppMainV2.java:70)

"Attach Listener" daemon prio=10 tid=0x000000000beee800 nid=0x2c54 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x000000000bee7800 nid=0x2fd0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x0000000002608800 nid=0x2fd8 in Object.wait() [0x000000000d1bf000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000007d5eb5798> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)

"Reference Handler" daemon prio=10 tid=0x0000000002601800 nid=0x2e30 in Object.wait() [0x000000000d06f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000007d5eb5320> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x000000000be41800 nid=0x2850 runnable 

"GC task thread#0 (ParallelGC)" prio=6 tid=0x0000000002555000 nid=0x24c4 runnable 

"GC task thread#1 (ParallelGC)" prio=6 tid=0x0000000002557000 nid=0x2d28 runnable 

"GC task thread#2 (ParallelGC)" prio=6 tid=0x0000000002558800 nid=0x1a58 runnable 

"GC task thread#3 (ParallelGC)" prio=6 tid=0x000000000255a800 nid=0x2eb8 runnable 

"VM Periodic Task Thread" prio=10 tid=0x000000000bf2f000 nid=0x2940 waiting on condition 

JNI global references: 135

Heap
 PSYoungGen      total 37696K, used 3878K [0x00000007d5eb0000, 0x00000007d88c0000, 0x0000000800000000)
  eden space 32320K, 12% used [0x00000007d5eb0000,0x00000007d6279bd8,0x00000007d7e40000)
  from space 5376K, 0% used [0x00000007d8380000,0x00000007d8380000,0x00000007d88c0000)
  to   space 5376K, 0% used [0x00000007d7e40000,0x00000007d7e40000,0x00000007d8380000)
 ParOldGen       total 86144K, used 0K [0x0000000781c00000, 0x0000000787020000, 0x00000007d5eb0000)
  object space 86144K, 0% used [0x0000000781c00000,0x0000000781c00000,0x0000000787020000)
 PSPermGen       total 21248K, used 3277K [0x000000077ca00000, 0x000000077dec0000, 0x0000000781c00000)
  object space 21248K, 15% used [0x000000077ca00000,0x000000077cd335b0,0x000000077dec0000)


Process finished with exit code 0

 

posted @ 2018-04-05 18:09  kingsleylam  阅读(325)  评论(0编辑  收藏  举报