public class ReaderWriterLock
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
ReaderWriterLock.ReaderWriterNode
A node for the waiting list.
|
Modifier and Type | Field and Description |
---|---|
private java.util.ArrayList |
waiters
The waiting threads.
|
Constructor and Description |
---|
ReaderWriterLock()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private int |
firstWriter()
Returns the index of the first waiting writer.
|
private int |
getIndex(java.lang.Thread t)
Returns the index of a thread.
|
void |
lockRead()
Grab the read lock.
|
void |
lockWrite()
Grab the write lock.
|
void |
unlock()
Unlock.
|
public void lockRead()
public void lockWrite()
public void unlock()
private int firstWriter()
private int getIndex(java.lang.Thread t)
t
- the thread.