Package com.jogamp.common.util.locks
Interface Lock
- All Known Subinterfaces:
RecursiveLock,RecursiveThreadGroupLock,ThreadLock
- All Known Implementing Classes:
SingletonInstance
public interface Lock
Specifying a thread blocking lock implementation
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanEnable via the propertyjogamp.debug.Lockstatic final longThe defaultTIMEOUTvalue, of 5000L msstatic final longstatic final booleanEnable via the propertyjogamp.debug.Lock.TraceLock -
Method Summary
-
Field Details
-
DEBUG
static final boolean DEBUGEnable via the propertyjogamp.debug.Lock -
TRACE_LOCK
static final boolean TRACE_LOCKEnable via the propertyjogamp.debug.Lock.TraceLock -
DEFAULT_TIMEOUT
static final long DEFAULT_TIMEOUTThe defaultTIMEOUTvalue, of 5000L ms- See Also:
-
TIMEOUT
static final long TIMEOUTTheTIMEOUTforlock()in ms, defaults toDEFAULT_TIMEOUT.It can be overridden via the system property
jogamp.common.utils.locks.Lock.timeout.
-
-
Method Details
-
lock
Blocking until the lock is acquired by this Thread orTIMEOUTis reached.- Throws:
RuntimeException- in case ofTIMEOUT
-
tryLock
Blocking until the lock is acquired by this Thread ormaxwaitin ms is reached.- Parameters:
timeout- Maximum time in ms to wait to acquire the lock. If this value is zero, the call returns immediately either without being able to acquire the lock, or with acquiring the lock directly while ignoring any scheduling order.- Returns:
- true if the lock has been acquired within
maxwait, otherwise false - Throws:
InterruptedException
-
unlock
Release the lock.- Throws:
RuntimeException- in case the lock is not acquired by this thread.
-
isLocked
boolean isLocked()Query if locked
-