[concurrency-interest] Upgrading a RL to WL in ReentrantReadWriteLock
belaban at yahoo.com
Tue Dec 5 11:26:19 EST 2006
Apologies if this has been asked before - I tried to google and search
the concurrency-interest mailing list archives, to no avail (note that
the archives at
be searched ! It would be good if you guys could change this...).
We're using our own reentrant lock classes in JBossCache
(http://labs.jboss.com/portal/jbosscache/), but we'd like to replace
them with the java.util.concurrent.* equivalent classes. However, for
ReentrantReadWriteLock, we need upgrading capabilities from RLs tro WLs.
>From the documentation of RRWL:
* *Lock downgrading*
Reentrancy also allows downgrading from the write lock to a read
lock, by acquiring the write lock, then the read lock and then
releasing the write lock. However, upgrading from a read lock to
the write lock is *not* possible.
What was the rationale for this ?
We would prefer *not* to release the RL first, then acquire the WL, as
other threads might then be able to acquire RLs or WLs after the
original thread releases the RL but before it acquires the WL.
Lead JGroups / JBoss Clustering team
JBoss - a division of Red Hat
More information about the Concurrency-interest