|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.boylesoftware.cb2.util.AccessGuard
This class provides service for synchronizing access to a guarded
object from multiple concurrent threads. Each thread may be either
a reader or a writer. When a reader has started working with the
target object by calling startReading() method any
writer trying to call startWriting() will wait until
all readers free the object by calling endReading(),
while readers continue to be able register with
startReading() calls. When a writer gets access to the
object by calling startWriting() any other reader or
writer will wait until the writer frees the object by calling
endWriting().
If your code can throw an exception it is recommended to have
"end" methods calls in finally blocks.
| Constructor Summary | |
AccessGuard()
Constructs a guard. |
|
| Method Summary | |
void |
endReading()
Unregisters a reader. |
void |
endWriting()
Unregisters a writer. |
void |
startReading()
Registers a reader. |
void |
startWriting()
Registers a writer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public AccessGuard()
| Method Detail |
public void startReading()
public void endReading()
public void startWriting()
public void endWriting()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||