我的应用程序部署在Weblogic 10.3.5上,带有java 6 update 30.我在执行此代码行时遇到以下错误:
lock.readLock().lock();
try {
holder = cache.get(configName);
// If it exists in the cache, return it
if (holder != null)
return holder;
} finally {
lock.readLock().unlock();
}
虽然在类加载期间初始化了锁:
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
缓存是:
private Map<String, ConfigurationHolder> cache = new HashMap<String,ConfigurationHolder>();
突然抛出了IllegalMonitorStateException:
Caused by: java.lang.IllegalMonitorStateException
at java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryReleaseShared(ReentrantReadWriteLock.java:363)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.releaseShared(AbstractQueuedSynchronizer.java:1317)
at java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.unlock(ReentrantReadWriteLock.java:745)
我在这种情况下阅读了here类似的描述。
任何人都知道为什么会这样?