public class InterProcessMultiLock extends java.lang.Object implements InterProcessLock
| Constructor and Description |
|---|
InterProcessMultiLock(CuratorFramework client,
java.util.List<java.lang.String> paths)
Creates a multi lock of
InterProcessMutexs |
InterProcessMultiLock(java.util.List<InterProcessLock> locks)
Creates a multi lock of any type of inter process lock
|
| Modifier and Type | Method and Description |
|---|---|
void |
acquire()
Acquire the mutex - blocking until it's available.
|
boolean |
acquire(long time,
java.util.concurrent.TimeUnit unit)
Acquire the mutex - blocks until it's available or the given time expires.
|
boolean |
isAcquiredInThisProcess()
Returns true if the mutex is acquired by a thread in this JVM
|
void |
release()
Perform one release of the mutex if the calling thread is the same thread that acquired it.
|
public InterProcessMultiLock(CuratorFramework client, java.util.List<java.lang.String> paths)
InterProcessMutexsclient - the clientpaths - list of paths to manage in the order that they are to be lockedpublic InterProcessMultiLock(java.util.List<InterProcessLock> locks)
locks - the lockspublic void acquire()
throws java.lang.Exception
InterProcessLock.release()acquire in interface InterProcessLockjava.lang.Exception - ZK errors, interruptions, another thread owns the lockpublic boolean acquire(long time,
java.util.concurrent.TimeUnit unit)
throws java.lang.Exception
InterProcessLock.release()acquire in interface InterProcessLocktime - time to waitunit - time unitjava.lang.Exception - ZK errors, interruptions, another thread owns the lockpublic void release()
throws java.lang.Exception
NOTE: locks are released in the reverse order that they were acquired.
release in interface InterProcessLockjava.lang.Exception - ZK errors, interruptions, current thread does not own the lockpublic boolean isAcquiredInThisProcess()
InterProcessLockisAcquiredInThisProcess in interface InterProcessLock