I use ReentrantLock, but something strange happend. Locked..
(JDK 6 Update 6, Redhat Enterprise 3)
class X {
private final ReentrantLock lock = new ReentrantLock();
// ...
public void m() {
lock.lock(); // block until condition holds
try {
// ... method body
} finally {
lock.unlock()
}
}
public void n() {
lock.lock(); // block until condition holds
try {
// ... method body
} finally {
lock.unlock()
}
}
}
private final ReentrantLock lock = new ReentrantLock();
// ...
public void m() {
lock.lock(); // block until condition holds
try {
// ... method body
} finally {
lock.unlock()
}
}
public void n() {
lock.lock(); // block until condition holds
try {
// ... method body
} finally {
lock.unlock()
}
}
}
Like below, many thread locked by a 0x58266548 .
Many threads locked on the ReentrantLock instance.. So.. My clusion is "removing ReentrantLock instance" in my code. There are bug reports related with ReentrantLock in bug.sun.com and web..
I changed "lock" to synchronized..
"Worker-17" prio=10 tid=0x4c504400 nid=0x1179 waiting on condition [0x490be000..0x490beea0]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x58266548> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:778)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1114)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:186)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
.. my package-source...
'java core' 카테고리의 다른 글
JMX Test Code (0) | 2009.12.31 |
---|---|
Studing JVM this week (0) | 2009.12.11 |
Java Garbage Collection, Monitoring and Tuning (0) | 2009.12.09 |
Eclipse(JVM) Crash (0) | 2009.12.09 |
Cheking JMX Port Alive (0) | 2009.11.19 |