public interface RLock extends Lock, RExpirable, RLockAsync
Lock
Implements reentrant lock.
Use getHoldCount()
to get a holds count.Modifier and Type | Method and Description |
---|---|
void |
forceUnlock()
Unlocks lock independently of state
|
int |
getHoldCount()
Number of holds on this lock by the current thread
|
boolean |
isHeldByCurrentThread()
Checks if this lock is held by the current thread
|
boolean |
isLocked()
Checks if this lock locked by any thread
|
void |
lock(long leaseTime,
TimeUnit unit)
Acquires the lock.
|
void |
lockInterruptibly(long leaseTime,
TimeUnit unit)
Acquires the lock.
|
boolean |
tryLock(long waitTime,
long leaseTime,
TimeUnit unit)
Returns
true as soon as the lock is acquired. |
lock, lockInterruptibly, newCondition, tryLock, tryLock, unlock
clearExpire, expire, expireAt, expireAt, remainTimeToLive
delete, getCodec, getName, isExists, migrate, move, rename, renamenx, touch
forceUnlockAsync, lockAsync, lockAsync, tryLockAsync, tryLockAsync, tryLockAsync, unlockAsync
clearExpireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
deleteAsync, isExistsAsync, migrateAsync, moveAsync, renameAsync, renamenxAsync, touchAsync
void lockInterruptibly(long leaseTime, TimeUnit unit) throws InterruptedException
If the lock is not available then the current thread becomes
disabled for thread scheduling purposes and lies dormant until the
lock has been acquired.
If the lock is acquired, it is held until unlock
is invoked,
or until leaseTime have passed
since the lock was granted - whichever comes first.
leaseTime
- the maximum time to hold the lock after granting it,
before automatically releasing it if it hasn't already been released by invoking unlock
.
If leaseTime is -1, hold the lock until explicitly unlocked.unit
- the time unit of the leaseTime
argumentInterruptedException
- - if the thread is interrupted before or during this method.boolean tryLock(long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException
true
as soon as the lock is acquired.
If the lock is currently held by another thread in this or any
other process in the distributed system this method keeps trying
to acquire the lock for up to waitTime
before
giving up and returning false
. If the lock is acquired,
it is held until unlock
is invoked, or until leaseTime
have passed since the lock was granted - whichever comes first.waitTime
- the maximum time to aquire the lockleaseTime
- lease timeunit
- time unittrue
if lock has been successfully acquiredInterruptedException
- - if the thread is interrupted before or during this method.void lock(long leaseTime, TimeUnit unit)
If the lock is not available then the current thread becomes
disabled for thread scheduling purposes and lies dormant until the
lock has been acquired.
If the lock is acquired, it is held until unlock
is invoked,
or until leaseTime milliseconds have passed
since the lock was granted - whichever comes first.
leaseTime
- the maximum time to hold the lock after granting it,
before automatically releasing it if it hasn't already been released by invoking unlock
.
If leaseTime is -1, hold the lock until explicitly unlocked.unit
- the time unit of the leaseTime
argumentvoid forceUnlock()
boolean isLocked()
true
if locked otherwise false
boolean isHeldByCurrentThread()
true
if held by current thread
otherwise false
int getHoldCount()
0
if this lock is not held by current threadCopyright © 2014–2017 The Redisson Project. All rights reserved.