我的应用程序部署在带有 java 6 update 30 的 Weblogic 10.3.5 上。执行此代码行时遇到以下错误:
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)
我在这里阅读了与这种情况类似的描述。
有人知道为什么会这样吗?