"BlockedThread-2"#14 prio=5 os_prio=31 tid=0x0000000146045000 nid=0x7a03 waiting for monitor entry [0x000000017214e000] java.lang.Thread.State: BLOCKED (on object monitor) at com.juzi.juc.Blocked.run(ReadStackLog.java:62) - waiting to lock <0x000000076aeda670> (a java.lang.Class for com.juzi.juc.Blocked) at java.lang.Thread.run(Thread.java:750)
"BlockedThread-1"#13 prio=5 os_prio=31 tid=0x0000000146044000 nid=0x7b03 waiting on condition [0x0000000171f42000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at com.juzi.juc.Blocked.run(ReadStackLog.java:62) - locked <0x000000076aeda670> (a java.lang.Class for com.juzi.juc.Blocked) at java.lang.Thread.run(Thread.java:750)
"WaitingThread"#12 prio=5 os_prio=31 tid=0x0000000146043000 nid=0x5903 in Object.wait() [0x0000000171d36000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x000000076aed7d50> (a java.lang.Class for com.juzi.juc.Waiting) at java.lang.Object.wait(Object.java:502) at com.juzi.juc.Waiting.run(ReadStackLog.java:43) - locked <0x000000076aed7d50> (a java.lang.Class for com.juzi.juc.Waiting) at java.lang.Thread.run(Thread.java:750)
"TimeWaitingThread"#11 prio=5 os_prio=31 tid=0x0000000146042000 nid=0x7c03 waiting on condition [0x0000000171b2a000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at com.juzi.juc.TimeWaiting.run(ReadStackLog.java:25) at java.lang.Thread.run(Thread.java:750)
"Monitor Ctrl-Break"#5 daemon prio=5 os_prio=31 tid=0x0000000123809000 nid=0x4603 runnable [0x0000000170cd6000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) at java.net.SocketInputStream.read(SocketInputStream.java:171) at java.net.SocketInputStream.read(SocketInputStream.java:141) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) - locked <0x000000076aca7168> (a java.io.InputStreamReader) at java.io.InputStreamReader.read(InputStreamReader.java:184) at java.io.BufferedReader.fill(BufferedReader.java:161) at java.io.BufferedReader.readLine(BufferedReader.java:324) - locked <0x000000076aca7168> (a java.io.InputStreamReader) at java.io.BufferedReader.readLine(BufferedReader.java:389) at com.intellij.rt.execution.application.AppMainV2$1.run(AppMainV2.java:53)
"Finalizer"#3 daemon prio=8 os_prio=31 tid=0x0000000143852800 nid=0x3303 in Object.wait() [0x00000001707a6000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x000000076ab09528> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144) - locked <0x000000076ab09528> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:188)
"Reference Handler"#2 daemon prio=10 os_prio=31 tid=0x0000000143850000 nid=0x3603 in Object.wait() [0x000000017059a000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x000000076ab070a8> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Object.java:502) at java.lang.ref.Reference.tryHandlePending(Reference.java:191) - locked <0x000000076ab070a8> (a java.lang.ref.Reference$Lock) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)
几个需要注意的点:
1)"BlockedThread-2"状态为BLOCKED,我们能从中发现死锁情况,根据日志- waiting to lock <0x000000076aeda670> (a java.lang.Class for com.juzi.juc.Blocked),还可以定位到具体的类com.juzi.juc.Blocked
2)"BlockedThread-1"状态为TIMED_WAITING,这个和我们的代码意图一直,除此之外,根据日志,我们还可以发现- locked <0x000000076aeda670> (a java.lang.Class for com.juzi.juc.Blocked),该线程已经获取了锁