Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

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


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.


Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

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