GigaSpaces XAP 9.7.2 API

com.sun.jini.thread
Class ReadersWriter

java.lang.Object
  extended by com.sun.jini.thread.ReadersWriter

public class ReadersWriter
extends Object

An Object to control the concurrent state. Allows multiple readers or a single writer. Waiting writers have priority over new readers. Waiting priority writers have priority over waiting regular writers. A single thread cannot hold a lock more than once.

Author:
Sun Microsystems, Inc.

Nested Class Summary
static class ReadersWriter.ConcurrentLockException
          InterruptedException transformed to a runtime exception.
 
Constructor Summary
ReadersWriter()
           
 
Method Summary
 void priorityWriteLock()
          Obtain a priority write lock.
 void readerWait(Object notifier, long time)
          Release a read lock, wait the given period of time or until notified by notifier, then obtain a read lock again.
 void readLock()
          Obtain a read lock.
 void readUnlock()
          Release a read lock.
 void waiterNotify(Object notifier)
          Wake up any threads waiting on this notifier.
 void writeLock()
          Obtain a regular write lock.
 void writerWait(Object notifier, long time)
          Release a write lock, wait the given period of time or until notified by notifier, then obtain a regular write lock again.
 void writeUnlock()
          Release a (regular or priority) write lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadersWriter

public ReadersWriter()
Method Detail

readLock

public void readLock()
Obtain a read lock. Multiple concurrent readers allowed.


readUnlock

public void readUnlock()
Release a read lock.


writeLock

public void writeLock()
Obtain a regular write lock. Only a single writer allowed at once.


priorityWriteLock

public void priorityWriteLock()
Obtain a priority write lock. Only a single writer allowed at once.


writeUnlock

public void writeUnlock()
Release a (regular or priority) write lock.


readerWait

public void readerWait(Object notifier,
                       long time)
Release a read lock, wait the given period of time or until notified by notifier, then obtain a read lock again. Throws ConcurrentLockException if the thread gets interrupted; in that case, the read lock is still held.


writerWait

public void writerWait(Object notifier,
                       long time)
Release a write lock, wait the given period of time or until notified by notifier, then obtain a regular write lock again. Throws ConcurrentLockException if the thread gets interrupted; in that case, the write lock is still held.


waiterNotify

public void waiterNotify(Object notifier)
Wake up any threads waiting on this notifier. In general, because there is no wakeup-waiting flag, this method must be called from a thread that holds a lock that conflicts with the lock that the waiter was holding. If the waiter calls writerWait, then waiterNotify can be called either under a readLock or a writeLock, but if the waiter calls readerWait, then waiterNotify should only be called under a writeLock.


GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.