com.netflix.curator.framework.recipes.locks
Interface InterProcessLock

All Known Implementing Classes:
InterProcessMultiLock, InterProcessMutex, InterProcessSemaphoreMutex

public interface InterProcessLock


Method Summary
 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.
 

Method Detail

acquire

void acquire()
             throws java.lang.Exception
Acquire the mutex - blocking until it's available. Note: the same thread can call acquire re-entrantly. Each call to acquire must be balanced by a call to release()

Throws:
java.lang.Exception - ZK errors, interruptions, another thread owns the lock

acquire

boolean acquire(long time,
                java.util.concurrent.TimeUnit unit)
                throws java.lang.Exception
Acquire the mutex - blocks until it's available or the given time expires. Note: the same thread can call acquire re-entrantly. Each call to acquire that returns true must be balanced by a call to release()

Parameters:
time - time to wait
unit - time unit
Returns:
true if the mutex was acquired, false if not
Throws:
java.lang.Exception - ZK errors, interruptions, another thread owns the lock

release

void release()
             throws java.lang.Exception
Perform one release of the mutex if the calling thread is the same thread that acquired it. If the thread had made multiple calls to acquire, the mutex will still be held when this method returns.

Throws:
java.lang.Exception - ZK errors, interruptions, current thread does not own the lock

isAcquiredInThisProcess

boolean isAcquiredInThisProcess()
Returns true if the mutex is acquired by a thread in this JVM

Returns:
true/false