public interface DistributedLock
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
isHeldByCurrentThread()
检查锁是否由当前线程持有
|
boolean |
isHeldByThread(long threadId)
检查锁是否由定义了threadId的线程持有
|
boolean |
isLocked()
是否锁住
|
void |
lock(long leaseTime,
TimeUnit unit)
获取锁
|
boolean |
tryLock()
获取锁
|
boolean |
tryLock(long waitTime,
long leaseTime,
TimeUnit unit)
获取锁
|
boolean |
tryLock(long waitTime,
TimeUnit unit)
获取锁
|
void |
unlock()
释放锁
|
boolean tryLock(long waitTime,
long leaseTime,
TimeUnit unit)
throws InterruptedException
waitTime - 等待时间leaseTime - 释放时间unit - 时间单位InterruptedException - 中断异常boolean tryLock(long waitTime,
TimeUnit unit)
throws InterruptedException
waitTime - 等待时间unit - 时间单位InterruptedException - 中断异常boolean tryLock()
throws InterruptedException
InterruptedException - 中断异常void lock(long leaseTime,
TimeUnit unit)
leaseTime - 释放时间unit - 时间单位void unlock()
boolean isLocked()
boolean isHeldByThread(long threadId)
threadId - threadIdboolean isHeldByCurrentThread()
Copyright © 2025 Pivotal Software, Inc.. All rights reserved.