Log4j 1.3alpha-8

org.apache.log4j.helpers
Class ReaderWriterLock

java.lang.Object
  |
  +--org.apache.log4j.helpers.ReaderWriterLock

public class ReaderWriterLock
extends Object

A RederWriterLock allows multiple readers to obtain the lock at the same time but allows only one writer at a time. When both readers and writers wait to obtain the lock, priority is given to waiting writers. This lock is not reentrant. It is possible for a writer in possession of a writer lock to fail to obtain a reader lock. The same goes for reader in possession of a reader lock. It can fail to obtain a writer lock. THIS LOCK IS NOT RENTRANT. It is the developer's responsability to retstrict the use of this lock to small segments of code where reentrancy can be avoided. Note that the RederWriterLock is only useful in cases where a resource: 1) Has many frequent read operations performed on it 2) Only rarely is the resource modified (written) 3) Read operations are invoked by many different threads If any of the above conditions are not met, it is better to avoid this fancy lock.

Author:
Ceki Gülcü

Constructor Summary
ReaderWriterLock()
           
ReaderWriterLock(PrintWriter pw)
           
 
Method Summary
 void getReadLock()
           
 void getWriteLock()
           
 void releaseReadLock()
           
 void releaseWriteLock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReaderWriterLock

public ReaderWriterLock()

ReaderWriterLock

public ReaderWriterLock(PrintWriter pw)
Method Detail

getReadLock

public void getReadLock()

releaseReadLock

public void releaseReadLock()

getWriteLock

public void getWriteLock()

releaseWriteLock

public void releaseWriteLock()

Log4j 1.3alpha-8

Copyright © 2000-2006 Apache Software Foundation.
Licensed under the Apache License, Version 2.0.