Fully reentrant. We could still separate the shared and exclusive wait() sets for greater efficiency under circumstances of high contention, but it would require extra synchronizations even under low contention, so we'll leave this as is, and maybe write a different class that presumes large wait sets.
Because this class is reentrant, lock relinquishes can't be idempotent -- we have to keep track of precisely how many times the lock was acquired and then release. Clients therefore have to be very careful that every acquisition is matched by exactly one relinquish. The way to do this is to acquire locks immediately before a try lock, and putting the relinquish in the finally block. One should not attempt to acquire the locks within the try block, because if the lock acquisition is interrupted, the lock relinquish in the finally block will run without the lock acquisition having succeeded.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Thread | |
| pack-priv List | |
| pack-priv int | |
| pack-priv int | |
| pack-priv String | |
| pack-priv Set | |
| pack-priv Set |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | |
| public synchronized void | |
| private boolean | |
| private boolean | |
| public synchronized void | |
| public synchronized void | |
| pack-priv void | |
| public String |
| activeExclusive | back to summary |
|---|---|
| pack-priv Thread activeExclusive | |
| activeShared | back to summary |
|---|---|
| pack-priv List<E> activeShared | |
| exclusive_exclusive_reentries | back to summary |
|---|---|
| pack-priv int exclusive_exclusive_reentries | |
| exclusive_shared_reentries | back to summary |
|---|---|
| pack-priv int exclusive_shared_reentries | |
| name | back to summary |
|---|---|
| pack-priv String name | |
| waitingExclusive | back to summary |
|---|---|
| pack-priv Set<E> waitingExclusive | |
| waitingShared | back to summary |
|---|---|
| pack-priv Set<E> waitingShared | |
| ExactReentrantSharedUseExclusiveUseLock | back to summary |
|---|---|
| public ExactReentrantSharedUseExclusiveUseLock(String name) | |
| ExactReentrantSharedUseExclusiveUseLock | back to summary |
|---|---|
| public ExactReentrantSharedUseExclusiveUseLock() | |
| acquireExclusive | back to summary |
|---|---|
| public synchronized void acquireExclusive() throws InterruptedException Implements com. | |
| acquireShared | back to summary |
|---|---|
| public synchronized void acquireShared() throws InterruptedException Implements com. | |
| okayForExclusive | back to summary |
|---|---|
| private boolean okayForExclusive(Thread t) | |
| okayForShared | back to summary |
|---|---|
| private boolean okayForShared() | |
| relinquishExclusive | back to summary |
|---|---|
| public synchronized void relinquishExclusive() Implements com. | |
| relinquishShared | back to summary |
|---|---|
| public synchronized void relinquishShared() Implements com. | |
| status | back to summary |
|---|---|
| pack-priv void status(String afterMethod) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |