|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uwcse.location.objects.MultiReadSingleWriteLock
This class implements a reader-writer lock allowing parallel reads but FIFO
serialized atomic writes. Reads have priority in that when an active write
releases its lock, pending reads will execute before other pending writes.
Methods should use a try-finally structure to request and release locks to
avoid erroneous starvation or deadlock.
Multiple locks and deadlock: Note that in this implementation, attempts by a
thread to acquire another lock when it already holds one will very likely
result in deadlock.
| Nested Class Summary | |
static class |
MultiReadSingleWriteLock.UnitTest
A unit test for the lock. |
| Constructor Summary | |
MultiReadSingleWriteLock()
Create a multi-reader single-writer resource lock. |
|
| Method Summary | |
void |
acquireReadLock()
Requests the read lock and block until a read operation can be performed safely. |
void |
acquireWriteLock()
Request the write lock and block until a write operation can be performed safely. |
void |
releaseReadLock()
Release a previously acquired read lock. |
void |
releaseWriteLock()
Release a previously acquired write lock. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MultiReadSingleWriteLock()
| Method Detail |
public void acquireReadLock()
releaseReadLock()public void releaseReadLock()
acquireReadLock()public void acquireWriteLock()
releaseWriteLock()public void releaseWriteLock()
acquireWriteLock()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||