public abstract class AbstractDLock extends Object implements DLock
| 构造器和说明 |
|---|
AbstractDLock() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
lock() |
void |
lock(long ttl,
TimeUnit ttlUnit,
boolean interruptibly)
没拿到锁之前死等,拿到锁之后,在指定的 ttl 时间后,锁自动过期。
|
void |
lockInterruptibly() |
Condition |
newCondition() |
boolean |
tryLock()
只进行一次尝试,锁成功 返回 true, 否则返回false
|
boolean |
tryLock(long tryTime,
TimeUnit tryTimeUnit) |
boolean |
tryLock(long tryTime,
TimeUnit tryTimeUnit,
long ttl,
TimeUnit ttlUnit)
拿到锁之前,最多尝试 lockTime 时间,拿到锁之后,锁在 ttl 后过期
|
boolean |
tryLock(long tryTime,
TimeUnit tryUnit,
long ttl,
TimeUnit ttlUnit,
boolean interruptibly) |
void |
unlock() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforceUnlockpublic void lockInterruptibly()
throws InterruptedException
lockInterruptibly 在接口中 DLocklockInterruptibly 在接口中 LockInterruptedExceptionpublic void lock(long ttl,
TimeUnit ttlUnit,
boolean interruptibly)
throws InterruptedException
DLocklock 在接口中 DLockttl - 指定的锁定时间,即拿到锁后过期时间ttlUnit - 单位interruptibly - 在尝试加锁期间,能否被打断InterruptedException - 锁住后,被打断时,抛出该异常public boolean tryLock(long tryTime,
TimeUnit tryTimeUnit,
long ttl,
TimeUnit ttlUnit)
DLockpublic boolean tryLock(long tryTime,
TimeUnit tryUnit,
long ttl,
TimeUnit ttlUnit,
boolean interruptibly)
throws InterruptedException
tryLock 在接口中 DLockInterruptedExceptionpublic boolean tryLock(long tryTime,
TimeUnit tryTimeUnit)
public boolean tryLock()
DLockpublic Condition newCondition()
newCondition 在接口中 LockCopyright © 2022. All rights reserved.