net.sf.ehcache.concurrent
Interface Sync

All Known Implementing Classes:
ReadWriteLockSync

public interface Sync

 

Field Summary
static long ONE_CENTURY
          One century in milliseconds; convenient as a time-out value
static long ONE_DAY
          One day, in milliseconds; convenient as a time-out value *
static long ONE_HOUR
          One hour, in milliseconds; convenient as a time-out value *
static long ONE_MINUTE
          One minute, in milliseconds; convenient as a time-out value *
static long ONE_SECOND
          One second, in milliseconds; convenient as a time-out value *
static long ONE_WEEK
          One week, in milliseconds; convenient as a time-out value *
static long ONE_YEAR
          One year in milliseconds; convenient as a time-out value Not that it matters, but there is some variation across standard sources about value at msec precision.
 
Method Summary
 boolean isHeldByCurrentThread(LockType type)
          Returns true is this is lock is held at given level by the current thread.
 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.
 

Field Detail

ONE_SECOND

static final long ONE_SECOND
One second, in milliseconds; convenient as a time-out value *

See Also:
Constant Field Values

ONE_MINUTE

static final long ONE_MINUTE
One minute, in milliseconds; convenient as a time-out value *

See Also:
Constant Field Values

ONE_HOUR

static final long ONE_HOUR
One hour, in milliseconds; convenient as a time-out value *

See Also:
Constant Field Values

ONE_DAY

static final long ONE_DAY
One day, in milliseconds; convenient as a time-out value *

See Also:
Constant Field Values

ONE_WEEK

static final long ONE_WEEK
One week, in milliseconds; convenient as a time-out value *

See Also:
Constant Field Values

ONE_YEAR

static final long ONE_YEAR
One year in milliseconds; convenient as a time-out value Not that it matters, but there is some variation across standard sources about value at msec precision. The value used is the same as in java.util.GregorianCalendar

See Also:
Constant Field Values

ONE_CENTURY

static final long ONE_CENTURY
One century in milliseconds; convenient as a time-out value

See Also:
Constant Field Values
Method Detail

lock

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

Parameters:
type - the lock type to acquire

tryLock

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

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

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

Parameters:
type - the lock type to acquire

isHeldByCurrentThread

boolean isHeldByCurrentThread(LockType type)
Returns true is this is lock is held at given level by the current thread.

Parameters:
type - the lock type to test
Returns:
true if the lock is held