我从jstack
获得了线程转储。
它显示两个线程锁定在同一个对象locked <0x00000000c0313ce0>
上。
当jstack显示第一个线程的堆栈跟踪不是同一时刻,当第二个thred堆栈跟踪时,是否可能出现这种情况?
或者还有什么可能导致这种锁定情况?
"Thread-1" #44 prio=5 os_prio=0 tid=0x000000001c418800 nid=0x922c in Object.wait() [0x0000000018ffe000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.h2.mvstore.db.MVTable.doLock1(MVTable.java:242)
at org.h2.mvstore.db.MVTable.lock(MVTable.java:167)
- locked <0x00000000c0313ce0> (a org.h2.engine.Database)
at org.h2.engine.Database.lockMeta(Database.java:896)
at org.h2.engine.Database.removeMeta(Database.java:919)
- locked <0x00000000c0313ce0> (a org.h2.engine.Database)
at org.h2.table.Table.removeChildrenAndResources(Table.java:525)
at org.h2.mvstore.db.MVTable.removeChildrenAndResources(MVTable.java:799)
at org.h2.engine.Session.cleanTempTables(Session.java:830)
- locked <0x00000000c0313ce0> (a org.h2.engine.Database)
at org.h2.engine.Session.close(Session.java:708)
at org.h2.engine.Database.closeAllSessionsException(Database.java:1186)
- locked <0x00000000c0313ce0> (a org.h2.engine.Database)
at org.h2.engine.Database.close(Database.java:1224)
- locked <0x00000000c0313ce0> (a org.h2.engine.Database)
at org.h2.engine.DatabaseCloser.run(DatabaseCloser.java:63)
"Resource Destroyer in BasicResourcePool.close()" #110 daemon prio=5 os_prio=0 tid=0x000000001c41a000 nid=0x2d44 in Object.wait() [0x000000001b6ae000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.h2.mvstore.db.MVTable.doLock1(MVTable.java:242)
at org.h2.mvstore.db.MVTable.lock(MVTable.java:167)
- locked <0x00000000c0313ce0> (a org.h2.engine.Database)
at org.h2.engine.Database.lockMeta(Database.java:896)
at org.h2.engine.Database.removeMeta(Database.java:919)
- locked <0x00000000c0313ce0> (a org.h2.engine.Database)
at org.h2.table.Table.removeChildrenAndResources(Table.java:525)
at org.h2.mvstore.db.MVTable.removeChildrenAndResources(MVTable.java:799)
at org.h2.engine.Session.cleanTempTables(Session.java:830)
- locked <0x00000000c0313ce0> (a org.h2.engine.Database)
at org.h2.engine.Session.close(Session.java:708)
at org.h2.jdbc.JdbcConnection.close(JdbcConnection.java:383)
- locked <0x00000000ede38ce0> (a org.h2.engine.Session)
- locked <0x00000000ede37708> (a org.h2.jdbc.JdbcConnection)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:642)
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:255)
- locked <0x00000000ee186430> (a com.mchange.v2.c3p0.impl.NewPooledConnection)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:621)
- locked <0x00000000ee186490> (a java.lang.Object)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1065)
at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:1090)
at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:1051)
at com.mchange.v2.resourcepool.BasicResourcePool.access$100(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$5.run(BasicResourcePool.java:1305)
答案 0 :(得分:1)
这些线程2没有锁定对象:他们都在o.wait()
调用同一个对象o
。
请记住,o.wait()
首先释放对象o
上的锁定。然后它等待一些其他线程通知对象,然后在返回给调用者之前重新获取锁。