I am getting a java.lang.IllegalStateMonitorException when trying to unlock a read lock as follows: ReentrantReadWriteLock.Readlock.unlock(). I have several threads which are locking and unlocking the readlock of a given object.
A reentrant write lock intrinsically defines an owner and can only be released by the thread that acquired it. In contrast, in this implementation, the read lock has no concept of ownership, and there is no requirement that the thread releasing a read lock is the same as the one that acquired it. However, this property is not guaranteed to hold in future implementations of this class.
My question is why am I getting the exception on a Readlock?
This may be a silly question, but are you certain that you successfully called lock() before calling unlock()? Or more precisely, are you sure you called lock() at least as many times as you called unlock()? Perhaps you could show the code that performs the lock() and unlock().
"I'm not back." - Bill Harding, Twister
Joined: Feb 23, 2006
Thank you. I just found that there were more locks than unlocks (2 more locks). That was it. It took awhile to find.