2016-01-18 55 views
1

我有從jstack線程轉儲。 它顯示兩個線程鎖定在同一個對象locked <0x00000000c0313ce0>上。 當jstack顯示第一個線程的堆棧跟蹤不是在同一時刻,當它爲第二個堆棧跟蹤時,它可能出現這種情況嗎? 還有什麼可能導致這種鎖定情況?jstack線程轉儲是否一致?

"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) 

回答

1

這些線程二者都不具備對象鎖定:他們是在一個o.wait()調用同一對象o都在等待。

記住,o.wait()首先解除針對對象o鎖。然後等待其他線程通知對象,然後在返回給調用者之前重新獲取鎖定。