Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.javatools.buffer
Class MultiLock

java.lang.Object
  extended by oracle.javatools.buffer.MultiLock


public final class MultiLock
extends java.lang.Object

Acquires and releases a set of ReadWriteLock as a unit. Ensures that locks are always taken in a consistent order to avoid lock ordering deadlocks.


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

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Method Detail

getReadLock

public static MultiLock getReadLock(ReadWriteLock... locks)
Get an instance which obtains read locks.
Parameters:
locks - the locks to be locked for reading
Returns:
the instance

getWriteLock

public static MultiLock getWriteLock(ReadWriteLock... locks)
Get an instance which obtains write locks.
Parameters:
locks - the locks to be locked for writing
Returns:
the instance

getCopyLock

public static MultiLock getCopyLock(ReadWriteLock src,
                                    ReadWriteLock dest)
Get an instance suitable for copying from a source to a destination. A read lock is taken on the source, and a write lock is taken on the destination.
Parameters:
src - the source lock
dest - the destination lock
Returns:
the instance

get

public 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.
Parameters:
read - the locks to be locked for reading
write - the locks to be locked for writing
Returns:
the instance

lock

public void lock()
Acquire the locks.

lockInterruptibly

public void lockInterruptibly()
                       throws java.lang.InterruptedException
Acquire the locks unless the calling thread is interrupted. If the thread is interrupted, any locks taken prior to the interruption are released.
Throws:
java.lang.InterruptedException - if the calling thread is interrupted

tryLock

public boolean tryLock()
Acquires the lock if it is possible to do so without blocking.
Returns:
true if the lock was acquired, false otherwise

unlock

public void unlock()
Release the locks.

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


Copyright © 1997, 2012, Oracle. All rights reserved.