|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.antiaction.critical.RWLock
RWLock implements simultanious reads and exclusive writes.
Based on an implementation by Scott Oaks & Henry Wong.
Java Threads ISBN 1-56592-418-5.
This class allows multiple threads read access to data simultaniously.
Write access is only granted for one thread at a time, with no read access simultaniously.
Internal Vector used to coordinate access.
This should be a very robust implementation.
In depth coverage of the subject can be found in the afore mentioned book.
Constructor Summary | |
RWLock()
Initialize object for use. |
Method Summary | |
void |
lockRead()
Obtain a read lock, blocks until access is granted. |
void |
lockWrite()
Obtain a write lock, blocks until exclusive access can be granted. |
void |
unlock()
Decreases the nest count, if zero the lock is released. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RWLock()
Method Detail |
public void lockRead()
lockWrite()
,
unlock()
public void lockWrite()
IllegalStateException
- if an attempt is made to upgrade a read lock to a write lock.lockRead()
,
unlock()
public void unlock()
IllegalStateException
- if no lock is held.lockRead()
,
lockWrite()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |