net.sf.ehcache.concurrent
Class ReadWriteLockSync
java.lang.Object
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReadWriteLockSync
public ReadWriteLockSync()
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 acquiremsec
- 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>
true