Package org.jfree.threads
Class ReaderWriterLock
java.lang.Object
org.jfree.threads.ReaderWriterLock
A reader-writer lock from "Java Threads" by Scott Oak and Henry Wong.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A node for the waiting list. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
waiters
The waiting threads.
-
-
Constructor Details
-
ReaderWriterLock
public ReaderWriterLock()Default constructor.
-
-
Method Details
-
lockRead
public void lockRead()Grab the read lock. -
lockWrite
public void lockWrite()Grab the write lock. -
unlock
public void unlock()Unlock. -
firstWriter
private int firstWriter()Returns the index of the first waiting writer.- Returns:
- The index.
-
getIndex
Returns the index of a thread.- Parameters:
t
- the thread.- Returns:
- The index.
-