org.apache.avalon.excalibur.concurrent
クラス ReadWriteLock

java.lang.Object
  |
  +--org.apache.avalon.excalibur.concurrent.ReadWriteLock

public class ReadWriteLock
extends java.lang.Object

Class implementing a read/write lock. The lock has three states - unlocked, locked for reading and locked for writing. If the lock is unlocked, anyone can aquire a read or write lock. If the lock is locked for reading, anyone can aquire a read lock, but no one can aquire a write lock. If the lock is locked for writing, no one can quire any type of lock.

When the lock is released, those threads attempting to aquire a write lock will take priority over those trying to get a read lock.

導入されたバージョン:
4.0
バージョン:
CVS $Revision: 1.7 $ $Date: 2001/12/11 09:53:28 $
作成者:
Leo Sutic

コンストラクタの概要
ReadWriteLock()
          Default constructor.
 
メソッドの概要
 void aquireRead()
          Attempts to aquire a read lock.
 void aquireWrite()
          Attempts to aquire a write lock.
 void release()
          Releases a lock.
 boolean tryAquireRead()
          Attempts to aquire a read lock.
 boolean tryAquireWrite()
          Attempts to aquire a write lock.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

ReadWriteLock

public ReadWriteLock()
Default constructor.
メソッドの詳細

aquireRead

public void aquireRead()
                throws java.lang.InterruptedException
Attempts to aquire a read lock. If no lock could be aquired the thread will wait until it can be obtained.
例外:
java.lang.InterruptedException - if the thread is interrupted while waiting for a lock.

aquireWrite

public void aquireWrite()
                 throws java.lang.InterruptedException
Attempts to aquire a write lock. If no lock could be aquired the thread will wait until it can be obtained.
例外:
java.lang.InterruptedException - if the thread is interrupted while waiting for a lock.

release

public void release()
Releases a lock. This method will release both types of locks.
例外:
java.lang.IllegalStateException - when an attempt is made to release an unlocked lock.

tryAquireRead

public boolean tryAquireRead()
Attempts to aquire a read lock. This method returns immediately.
戻り値:
true iff the lock was successfully obtained.

tryAquireWrite

public boolean tryAquireWrite()
Attempts to aquire a write lock. This method returns immediately.
戻り値:
true iff the lock was successfully obtained.


"Copyright ? 2001 Apache Jakarta Project. All Rights Reserved."