public interface Sync
Modifier and Type | Field and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
static final long ONE_SECOND
static final long ONE_MINUTE
static final long ONE_HOUR
static final long ONE_DAY
static final long ONE_WEEK
static final long ONE_YEAR
static final long ONE_CENTURY
void lock(LockType type)
type
- the lock type to acquireboolean tryLock(LockType type, long msec) throws java.lang.InterruptedException
type
- the lock type to acquiremsec
- timeoutjava.lang.InterruptedException
- Should the thread be interruptedvoid unlock(LockType type)
type
- the lock type to acquireboolean isHeldByCurrentThread(LockType type)
type
- the lock type to test