public interface ThreadLock extends Lock
Lock
features with convenient functionality.DEBUG, DEFAULT_TIMEOUT, TIMEOUT, TRACE_LOCK
Modifier and Type | Method and Description |
---|---|
Thread |
getOwner() |
boolean |
isLockedByOtherThread()
Query whether the lock is hold by the a thread other than the current thread.
|
boolean |
isOwner(Thread thread)
Query whether the lock is hold by the given thread.
|
void |
unlock(Runnable taskAfterUnlockBeforeNotify)
Execute the
Runnable taskAfterUnlockBeforeNotify while holding the exclusive lock. |
void |
validateLocked() |
boolean isLockedByOtherThread()
boolean isOwner(Thread thread)
Thread getOwner()
void validateLocked() throws RuntimeException
RuntimeException
- if current thread does not hold the lockvoid unlock(Runnable taskAfterUnlockBeforeNotify)
Runnable taskAfterUnlockBeforeNotify
while holding the exclusive lock.
Then release the lock.