Package net.sf.ehcache.concurrent
Class ReadWriteLockSync
- java.lang.Object
-
- net.sf.ehcache.concurrent.ReadWriteLockSync
-
-
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
Constructors Constructor Description ReadWriteLockSync()default constructor.ReadWriteLockSync(java.util.concurrent.locks.ReentrantReadWriteLock lock)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.locks.ReadWriteLockgetReadWriteLock()Gets theReadWriteLockbacking this sync.booleanisHeldByCurrentThread(LockType type)Returns true is this is lock is held at given level by the current thread.voidlock(LockType type)Acquire lock of LockType.READ or WRITEbooleantryLock(LockType type, long msec)Tries to acquire a LockType.READ or WRITE for a certain periodvoidunlock(LockType type)Releases the lock held by the current Thread.
-
-
-
Method Detail
-
lock
public void lock(LockType type)
Acquire lock of LockType.READ or WRITE
-
tryLock
public boolean tryLock(LockType type, long msec) throws java.lang.InterruptedException
Tries to acquire a LockType.READ or WRITE for a certain period
-
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
-
getReadWriteLock
public java.util.concurrent.locks.ReadWriteLock getReadWriteLock()
Gets theReadWriteLockbacking this sync.- Returns:
- the backing
ReadWriteLock
-
isHeldByCurrentThread
public boolean isHeldByCurrentThread(LockType type)
Returns true is this is lock is held at given level by the current thread.- Specified by:
isHeldByCurrentThreadin interfaceSync- Parameters:
type- the lock type to test- Returns:
- true if the lock is held
-
-