public interface OptimisticLock
StampedLock
The implementation may support optimistic locking if available at
the platform. If not supported, validate(long) returns always false.
This allows the identical usage pattern for both variants.
| Modifier and Type | Method and Description |
|---|---|
long |
readLock()
Non-exclusively acquires the lock, blocking if necessary
until available.
|
long |
tryOptimisticRead()
Returns a stamp that can later be validated, or zero
if exclusively locked.
|
void |
unlockRead(long stamp)
If the lock state matches the given stamp, releases the
non-exclusive lock.
|
void |
unlockWrite(long stamp)
If the lock state matches the given stamp, releases the
exclusive lock.
|
boolean |
validate(long stamp)
Returns true if the lock has not been exclusively acquired
since issuance of the given stamp.
|
long |
writeLock()
Exclusively acquires the lock, blocking if necessary
until available.
|
long writeLock()
long readLock()
long tryOptimisticRead()
unlockWrite(long) become visible.boolean validate(long stamp)
tryOptimisticRead() or a locking method
for this lock has no defined effect or result.stamp - a stamptrue if the lock has not been exclusively acquired
since issuance of the given stamp; else falsevoid unlockRead(long stamp)
stamp - a stamp returned by a read-lock operationIllegalMonitorStateException - if the stamp does
not match the current state of this lockvoid unlockWrite(long stamp)
stamp - a stamp returned by a write-lock operationIllegalMonitorStateException - if the stamp does
not match the current state of this lockcache2k API documentation. Copyright © 2000–2019 headissue GmbH, Munich.