public class ReadersWriter extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ReadersWriter.ConcurrentLockException
InterruptedException transformed to a runtime exception.
|
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.locks.ReadWriteLock |
lock |
private java.util.concurrent.locks.Lock |
readLock |
private java.util.concurrent.locks.Condition |
waitingPriorityWriter |
private java.util.concurrent.atomic.AtomicInteger |
waitingPriorityWriters |
private java.util.concurrent.locks.Condition |
waitingWriter |
private int |
waitingWriters |
private java.util.concurrent.locks.Lock |
writeLock |
Constructor and Description |
---|
ReadersWriter() |
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.locks.Condition |
newCondition()
Condition for use with writeLock()
|
void |
priorityWriteLock()
Obtain a priority write lock.
|
void |
readerWait(Object notifier,
long time)
Release a read lock, wait the given period of time or until
notified by notifier, then obtain a read lock again.
|
void |
readLock()
Obtain a read lock.
|
void |
readUnlock()
Release a read lock.
|
void |
waiterNotify(Object notifier)
Wake up any threads waiting on this notifier.
|
void |
writeLock()
Obtain a regular write lock.
|
void |
writerWait(Object notifier,
long time)
Deprecated.
use newCondition() and
Condition instead |
void |
writeUnlock()
Release a (regular or priority) write lock.
|
private int waitingWriters
private final java.util.concurrent.atomic.AtomicInteger waitingPriorityWriters
private final java.util.concurrent.locks.ReadWriteLock lock
private final java.util.concurrent.locks.Lock readLock
private final java.util.concurrent.locks.Lock writeLock
private final java.util.concurrent.locks.Condition waitingPriorityWriter
private final java.util.concurrent.locks.Condition waitingWriter
public java.util.concurrent.locks.Condition newCondition()
public void readLock()
public void readUnlock()
public void writeLock()
public void priorityWriteLock()
public void writeUnlock()
public void readerWait(Object notifier, long time)
@Deprecated public void writerWait(Object notifier, long time)
Condition
insteadpublic void waiterNotify(Object notifier)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.