public class DistributedLockImpl extends UnicastRemoteObject implements DistributedLock
| Modifier and Type | Field and Description |
|---|---|
static int |
HOUR |
ref| Constructor and Description |
|---|
DistributedLockImpl() |
DistributedLockImpl(long lockTimeout,
TimeUnit lockTimeoutUnit) |
| Modifier and Type | Method and Description |
|---|---|
long |
lock()
一直等直到获得锁为止
|
long |
tryLock(long time,
TimeUnit unit)
在time*unit时间内尝试lock
|
void |
unlock(long token) |
clone, exportObject, exportObject, exportObject, unexportObjectgetClientHost, getLog, setLogpublic static final int HOUR
public DistributedLockImpl()
throws RemoteException
RemoteExceptionpublic DistributedLockImpl(long lockTimeout,
TimeUnit lockTimeoutUnit)
throws RemoteException
lockTimeout - 锁超时时间,如果加锁的对象不解锁,超时之后自动解锁lockTimeoutUnit - 锁超时单位RemoteExceptionpublic long lock()
throws TimeoutException
DistributedLocklock in interface DistributedLockTimeoutExceptionpublic long tryLock(long time,
TimeUnit unit)
throws TimeoutException
DistributedLocktryLock in interface DistributedLockTimeoutExceptionpublic void unlock(long token)
unlock in interface DistributedLockCopyright © 2006–2018 TinyGroup. All rights reserved.