Is lock returned by ReentrantReadWriteLock equivalent to it's read and write locks?
Posted
by Todd
on Stack Overflow
See other posts from Stack Overflow
or by Todd
Published on 2010-04-25T13:27:51Z
Indexed on
2010/04/25
13:33 UTC
Read the original article
Hit count: 348
Hello,
I have been looking around for the answer to this, but no joy. In Java, is using the lock created by ReentrantReadWriteLock equivalent to getting the read and write locks as returned by readLock.lock() and writeLock.lock()? In other words, can I expect the read and write locks associated with the ReentrantReadWriteLock to be requested and held by synchronizing on the ReentrantReadWriteLock?
My gut says "no" since any object can be used for synchronization. I wouldn't think that there would be special behavior for ReentrantReadWriteLock. However, special behavior is the corner case of which I may not be aware.
Thanks, Todd
© Stack Overflow or respective owner