Java线程转储中的“ waiting on” vs“ waiting to lock” vs“ locked”

时间:2019-05-22 16:05:05

标签: java multithreading locking stack-trace blocked-threads

通过线程转储,我看到了几个已阻塞的线程,但是有些只有“等待锁定”,有些却只有“等待开启”,而只有一个RUNNABLE线程大概已经获得了锁。我的问题是,为什么有些“等待锁定”而另一些“等待发生”?另外,“正在等待”的线程似乎具有锁定,但实际上没有持有该锁定的RUNNABLE线程,因为它说它已将对象锁定在堆栈跟踪的较低地址,所以为什么要阻塞它(如果它具有锁定) (或者没有锁)?

以下示例: 锁定的对象位于0x00000000c2ad4be8

等待中

"ajp-bio-10032-exec-15" daemon prio=10 tid=0x00007f888c02d000 nid=0x74c8 in Object.wait() [0x00007f8821792000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000c2ad4be8> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:503)
    at com.tibco.tibjms.TibjmsxLinkTcp.disconnect(TibjmsxLinkTcp.java:1026)

等待锁定

"ajp-bio-10032-exec-95" daemon prio=10 tid=0x00007f888c089800 nid=0x1e66 in Object.wait() [0x00007f881df4b000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000c2ad4be8> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:503)
    at com.tibco.tibjms.TibjmsxLinkTcp.disconnect(TibjmsxLinkTcp.java:1026)
    - locked <0x00000000c2ad4be8> (a java.lang.Object)
    at com.tibco.tibjms.TibjmsConnection._close(TibjmsConnection.java:2430)

最后是RUNNABLE线程

"ajp-bio-10032-exec-142" daemon prio=10 tid=0x00007f888c0b7000 nid=0x3657 runnable [0x00007f88167d4000]
   java.lang.Thread.State: RUNNABLE
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:713)
    - locked <0x00000000f022c5e0> (a com.tibco.tibjms.TibjmsxLinkTcp$LinkReader)
    at com.tibco.tibjms.TibjmsxLinkTcp.start(TibjmsxLinkTcp.java:968)
    - locked <0x00000000c2ad4be8> (a java.lang.Object)

0 个答案:

没有答案