Class LockSupport
- java.lang.Object
-
- org.apache.tapestry5.commons.internal.util.LockSupport
-
- Direct Known Subclasses:
AbstractResource
,AlertStorage
,ApplicationMessageCatalogObjectProvider
,AssetSourceImpl
,CachingObjectCreator
,InternalComponentResourcesImpl
,NamedSet
,OneShotLock
,TypeCoercerImpl
public abstract class LockSupport extends java.lang.Object
Base class for classes that need to manage a ReadWriteLock.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LockSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
acquireReadLock()
Locks the shared read lock.protected void
downgradeWriteLockToReadLock()
Takes the read lock then releases the write lock.protected void
releaseReadLock()
Releases the shared read lock.protected void
releaseWriteLock()
Releases the exclusive read lock.protected void
takeWriteLock()
Takes the exclusive write lock.protected void
upgradeReadLockToWriteLock()
Releases the read lock, then takes the write lock.
-
-
-
Constructor Detail
-
LockSupport
protected LockSupport()
-
-
Method Detail
-
acquireReadLock
protected final void acquireReadLock()
Locks the shared read lock. Any number of threads may lock the read lock at the same time.
-
takeWriteLock
protected final void takeWriteLock()
Takes the exclusive write lock. Once started, no other thread lock the read or write lock. When this method returns, this thread will have locked the write lock and no other thread will have either the read or write lock. Note that this thread must first drop the read lock (if it has it) before attempting to take the write lock, or this method will block forever.
-
releaseReadLock
protected final void releaseReadLock()
Releases the shared read lock.
-
releaseWriteLock
protected final void releaseWriteLock()
Releases the exclusive read lock.
-
upgradeReadLockToWriteLock
protected final void upgradeReadLockToWriteLock()
Releases the read lock, then takes the write lock. There's a short window where the thread will have neither lock: during that window, some other thread may have a chance to take the write lock. In code, you'll often see a second check inside the code that has the write lock to see if the update to perform is still necessary.
-
downgradeWriteLockToReadLock
protected final void downgradeWriteLockToReadLock()
Takes the read lock then releases the write lock.
-
-