public final class MultiLock
extends java.lang.Object
ReadWriteLock as a unit.  Ensures
 that locks are always taken in a consistent order to avoid lock ordering
 deadlocks.| Modifier and Type | Method and Description | 
|---|---|
static MultiLock | 
get(java.util.Collection<ReadWriteLock> read,
   java.util.Collection<ReadWriteLock> write)
Get a lock instance which obtains a mixture of read and write locks. 
 | 
static MultiLock | 
getCopyLock(ReadWriteLock src,
           ReadWriteLock dest)
Get an instance suitable for copying from a source to a destination. 
 | 
static MultiLock | 
getReadLock(ReadWriteLock... locks)
Get an instance which obtains read locks. 
 | 
static MultiLock | 
getWriteLock(ReadWriteLock... locks)
Get an instance which obtains write locks. 
 | 
void | 
lock()
Acquire the locks. 
 | 
void | 
lockInterruptibly()
Acquire the locks unless the calling thread is interrupted. 
 | 
boolean | 
tryLock()
Acquires the lock if it is possible to do so without blocking. 
 | 
void | 
unlock()
Release the locks. 
 | 
public static MultiLock getReadLock(ReadWriteLock... locks)
locks - the locks to be locked for readingpublic static MultiLock getWriteLock(ReadWriteLock... locks)
locks - the locks to be locked for writingpublic static MultiLock getCopyLock(ReadWriteLock src, ReadWriteLock dest)
src - the source lockdest - the destination lockpublic static MultiLock get(java.util.Collection<ReadWriteLock> read, java.util.Collection<ReadWriteLock> write)
read - the locks to be locked for readingwrite - the locks to be locked for writingpublic void lock()
public void lockInterruptibly()
                       throws java.lang.InterruptedException
java.lang.InterruptedException - if the calling thread is interruptedpublic boolean tryLock()
true if the lock was acquired, false otherwisepublic void unlock()