public interface RLock extends Lock, RLockAsync
Lock
Implements re-entrant lock.Modifier and Type | Method and Description |
---|---|
boolean |
forceUnlock()
Unlocks the lock independently of its state
|
int |
getHoldCount()
Number of holds on this lock by the current thread
|
String |
getName()
Returns name of object
|
boolean |
isHeldByCurrentThread()
Checks if this lock is held by the current thread
|
boolean |
isHeldByThread(long threadId)
Checks if the lock is held by thread with defined
threadId |
boolean |
isLocked()
Checks if the lock locked by any thread
|
void |
lock(long leaseTime,
TimeUnit unit)
Acquires the lock with defined
leaseTime . |
void |
lockInterruptibly(long leaseTime,
TimeUnit unit)
Acquires the lock with defined
leaseTime . |
long |
remainTimeToLive()
Remaining time to live of the lock
|
boolean |
tryLock(long waitTime,
long leaseTime,
TimeUnit unit)
Tries to acquire the lock with defined
leaseTime . |
lock, lockInterruptibly, newCondition, tryLock, tryLock, unlock
forceUnlockAsync, getHoldCountAsync, isLockedAsync, lockAsync, lockAsync, lockAsync, lockAsync, remainTimeToLiveAsync, tryLockAsync, tryLockAsync, tryLockAsync, tryLockAsync, tryLockAsync, unlockAsync, unlockAsync
String getName()
void lockInterruptibly(long leaseTime, TimeUnit unit) throws InterruptedException
leaseTime
.
Waits if necessary until lock became available.
Lock will be released automatically after defined leaseTime
interval.leaseTime
- the maximum time to hold the lock after it's acquisition,
if it hasn't already been released by invoking unlock
.
If leaseTime is -1, hold the lock until explicitly unlocked.unit
- the time unitInterruptedException
- - if the thread is interruptedboolean tryLock(long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException
leaseTime
.
Waits up to defined waitTime
if necessary until the lock became available.
Lock will be released automatically after defined leaseTime
interval.waitTime
- the maximum time to acquire the lockleaseTime
- lease timeunit
- time unittrue
if lock is successfully acquired,
otherwise false
if lock is already set.InterruptedException
- - if the thread is interruptedvoid lock(long leaseTime, TimeUnit unit)
leaseTime
.
Waits if necessary until lock became available.
Lock will be released automatically after defined leaseTime
interval.leaseTime
- the maximum time to hold the lock after it's acquisition,
if it hasn't already been released by invoking unlock
.
If leaseTime is -1, hold the lock until explicitly unlocked.unit
- the time unitboolean forceUnlock()
true
if lock existed and now unlocked
otherwise false
boolean isLocked()
true
if locked otherwise false
boolean isHeldByThread(long threadId)
threadId
threadId
- Thread ID of locking threadtrue
if held by thread with given id
otherwise false
boolean isHeldByCurrentThread()
true
if held by current thread
otherwise false
int getHoldCount()
0
if this lock is not held by current threadlong remainTimeToLive()
Copyright © 2014–2020 Redisson. All rights reserved.