|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ILock
Distributed implementation of Lock
.
Lock mylock = Hazelcast.getLock(mylockobject); mylock.lock();
try {
// do something
} finally {
mylock.unlock();
}
//Lock on Map
IMap map = Hazelcast.getMap("customers"); map.lock("1");
try {
// do something
} finally {
map.unlock("1"); }
Lock
Method Summary | |
---|---|
void |
forceUnlock()
Releases the lock regardless of the lock owner. |
Object |
getKey()
Deprecated. use DistributedObject.getName() instead. |
int |
getLockCount()
Returns re-entrant lock hold count, regardless of lock ownership. |
long |
getRemainingLeaseTime()
Returns remaining lease time in milliseconds. |
boolean |
isLocked()
Returns whether this lock is locked or not. |
boolean |
isLockedByCurrentThread()
Returns whether this lock is locked by current thread or not. |
void |
lock()
|
void |
lock(long leaseTime,
TimeUnit timeUnit)
Acquires the lock for the specified lease time. |
Condition |
newCondition()
This method is not implemented! Use newCondition(String) instead. |
ICondition |
newCondition(String name)
Returns a new ICondition instance that is bound to this
ILock instance with given name. |
boolean |
tryLock()
|
boolean |
tryLock(long time,
TimeUnit unit)
|
void |
unlock()
Releases the lock. |
Methods inherited from interface java.util.concurrent.locks.Lock |
---|
lockInterruptibly |
Methods inherited from interface com.hazelcast.core.DistributedObject |
---|
destroy, getId, getName, getPartitionKey, getServiceName |
Method Detail |
---|
@Deprecated Object getKey()
DistributedObject.getName()
instead.
void lock()
lock
in interface Lock
boolean tryLock()
tryLock
in interface Lock
boolean tryLock(long time, TimeUnit unit) throws InterruptedException
tryLock
in interface Lock
InterruptedException
void unlock()
unlock
in interface Lock
void lock(long leaseTime, TimeUnit timeUnit)
After lease time, lock will be released..
If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.
leaseTime
- time to wait before releasing the lock.timeUnit
- unit of time for the lease time.
IllegalMonitorStateException
- if the current thread does not
hold this lockvoid forceUnlock()
Condition newCondition()
newCondition(String)
instead.
newCondition
in interface Lock
UnsupportedOperationException
ICondition newCondition(String name)
ICondition
instance that is bound to this
ILock
instance with given name.
Before waiting on the condition the lock must be held by the
current thread.
A call to Condition.await()
will atomically release the lock
before waiting and re-acquire the lock before the wait returns.
name
- identifier of the new condition instance
ICondition
instance for this ILock
instance
NullPointerException
- if name is null.boolean isLocked()
true
if this lock is locked, false
otherwise.boolean isLockedByCurrentThread()
true
if this lock is locked by current thread, false
otherwise.int getLockCount()
long getRemainingLeaseTime()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |