com.neeve.util
Class UtlReadWriteLock

java.lang.Object
  extended by com.neeve.util.UtlReadWriteLock

public class UtlReadWriteLock
extends Object

Class implementing a read write lock.

This class provides the functionality of read-write locks. A read-write lock allows multiple threads to acquire a read lock provided no other thread currently has a write lock on the same object. A thread can acquire a write lock if no other thread owns either a read lock or a write lock

This class IS NOT intended to be used by end users.

Threading:
This class is safe for concurrent access by multiple threads.

Method Summary
static UtlReadWriteLock create(String name)
          Create a read-write lock.
 void getReadLock()
          Acquire a read lock.
 void getReadLockUninterrupted()
          Convenience method that acquires a read lock but ignores the interrupted exception.
 void getWriteLock()
          Acquire a write lock.
 void getWriteLockUninterrupted()
          Convenience method that acquires a write lock but ignores the interrupted exception.
 void releaseLock()
          Release an acquired read or write lock
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static UtlReadWriteLock create(String name)
Create a read-write lock.

Parameters:
name - A name used to identify the lock for trace/debugging purposes
Returns:
Returns the created lock object
Threading:
This method is safe for concurrent access by multiple threads

getReadLock

public final void getReadLock()
                       throws InterruptedException
Acquire a read lock.

Throws:
InterruptedException - If another thread has interrupted the current thread while it was waiting for the lock to be released by other threads. The interrupted status of the current thread is cleared when this exception is thrown
Threading:
This method is safe for concurrent access by multiple threads

getReadLockUninterrupted

public final void getReadLockUninterrupted()
Convenience method that acquires a read lock but ignores the interrupted exception.

This method attempts to acquire a read lock but does not return in case the wait is interrupted. It case the wait is interrupted, the method traps the interrupted exception, puts out a warning and continues to wait for the read lock.

Threading:
This method is safe for concurrent access by multiple threads

getWriteLock

public final void getWriteLock()
                        throws InterruptedException
Acquire a write lock.

Throws:
InterruptedException - If another thread has interrupted the current thread while it was waiting for the lock to be released by other threads. The interrupted status of the current thread is cleared when this exception is thrown
Threading:
This method is safe for concurrent access by multiple threads

getWriteLockUninterrupted

public final void getWriteLockUninterrupted()
Convenience method that acquires a write lock but ignores the interrupted exception.

This method attempts to acquire a write lock but does not return in case the wait is interrupted. It case the wait is interrupted, the method traps the interrupted exception, puts out a warning and continues to wait for the write lock.

Threading:
This method is safe for concurrent access by multiple threads

releaseLock

public final void releaseLock()
Release an acquired read or write lock

Threading:
This method is safe for concurrent access by multiple threads


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.