Class LockSupport
java.lang.Object
org.apache.tapestry5.commons.internal.util.LockSupport
- Direct Known Subclasses:
AbstractResource
,AlertStorage
,ApplicationMessageCatalogObjectProvider
,AssetSourceImpl
,CachingObjectCreator
,InternalComponentResourcesImpl
,NamedSet
,OneShotLock
,TypeCoercerImpl
Base class for classes that need to manage a ReadWriteLock.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Locks the shared read lock.protected final void
Takes the read lock then releases the write lock.protected final void
Releases the shared read lock.protected final void
Releases the exclusive read lock.protected final void
Takes the exclusive write lock.protected final void
Releases the read lock, then takes the write lock.
-
Constructor Details
-
LockSupport
protected LockSupport()
-
-
Method Details
-
acquireReadLock
Locks the shared read lock. Any number of threads may lock the read lock at the same time. -
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
Releases the shared read lock. -
releaseWriteLock
Releases the exclusive read lock. -
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
Takes the read lock then releases the write lock.
-