|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sandev.basics.util.ReaderWriterLock
public class ReaderWriterLock
A multiple reader single writer lock utility.
| Field Summary | |
|---|---|
protected int |
activeReaders
The number of current readers. |
protected int |
activeWriters
The number of current writers. |
protected int |
waitingReaders
The number of waiting readers. |
protected java.util.List |
writerLocks
Our list of waiting writers. |
| Constructor Summary | |
|---|---|
ReaderWriterLock()
|
|
| Method Summary | |
|---|---|
protected void |
notifyReaders()
Notify waiting reader threads. |
protected void |
notifyWriters()
Release the next queued writer. |
void |
readCompleted()
Relinquish a read lock. |
void |
requestRead()
Request a read lock and block until it happens. |
void |
requestWrite()
Request the write lock and block until it happens. |
void |
writeCompleted()
Relinquish the write lock. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int activeReaders
protected int waitingReaders
protected int activeWriters
protected final java.util.List writerLocks
| Constructor Detail |
|---|
public ReaderWriterLock()
| Method Detail |
|---|
public void requestRead()
public void readCompleted()
public void requestWrite()
public void writeCompleted()
protected void notifyReaders()
protected void notifyWriters()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||