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, unexportObject
getClientHost, getLog, setLog
public static final int HOUR
public DistributedLockImpl() throws RemoteException
RemoteException
public DistributedLockImpl(long lockTimeout, TimeUnit lockTimeoutUnit) throws RemoteException
lockTimeout
- 锁超时时间,如果加锁的对象不解锁,超时之后自动解锁lockTimeoutUnit
- 锁超时单位RemoteException
public long lock() throws TimeoutException
DistributedLock
lock
in interface DistributedLock
TimeoutException
public long tryLock(long time, TimeUnit unit) throws TimeoutException
DistributedLock
tryLock
in interface DistributedLock
TimeoutException
public void unlock(long token)
unlock
in interface DistributedLock
Copyright © 2006–2018 TinyGroup. All rights reserved.