ehcache

net.sf.ehcache.concurrent
Class ReadWriteLockSync

java.lang.Object
  extended by net.sf.ehcache.concurrent.ReadWriteLockSync
All Implemented Interfaces:
java.lang.Comparable<ReadWriteLockSync>, Sync

public class ReadWriteLockSync
extends java.lang.Object
implements Sync, java.lang.Comparable<ReadWriteLockSync>

A simple ReadWriteLock synchronizer.

Author:
Alex Snaps

Field Summary
 
Fields inherited from interface net.sf.ehcache.concurrent.Sync
ONE_CENTURY, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ONE_YEAR
 
Constructor Summary
ReadWriteLockSync()
           
 
Method Summary
 int compareTo(ReadWriteLockSync o)
          
 void lock(LockType type)
          Acquire lock of LockType.READ or WRITE
 boolean tryLock(LockType type, long msec)
          Tries to acquire a LockType.READ or WRITE for a certain period
 void unlock(LockType type)
          Releases the lock held by the current Thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadWriteLockSync

public ReadWriteLockSync()
Method Detail

lock

public void lock(LockType type)
Acquire lock of LockType.READ or WRITE

Specified by:
lock in interface Sync
Parameters:
type - the lock type to acquire

tryLock

public boolean tryLock(LockType type,
                       long msec)
                throws java.lang.InterruptedException
Tries to acquire a LockType.READ or WRITE for a certain period

Specified by:
tryLock in interface Sync
Parameters:
type - the lock type to acquire
msec - timeout
Returns:
true if the lock got acquired, false otherwise
Throws:
java.lang.InterruptedException - Should the thread be interrupted

unlock

public void unlock(LockType type)
Releases the lock held by the current Thread. In case of a LockType.WRITE, should the lock not be held by the current Thread, nothing happens

Specified by:
unlock in interface Sync
Parameters:
type - the lock type to acquire

compareTo

public int compareTo(ReadWriteLockSync o)

Specified by:
compareTo in interface java.lang.Comparable<ReadWriteLockSync>

ehcache

true