Package dev.gmitch215.bytebox.locks
Interface Lock
- All Known Implementing Classes:
ReentrantLock
public interface Lock
java.util.concurrent.locks.Lock, which the class library does not carry.- Since:
- 1.0.3
-
Method Summary
Modifier and TypeMethodDescriptionvoidlock()Takes the lock, suspending the caller until it is free.voidTakes the lock, giving up if the caller is interrupted first.Returns a condition bound to this lock.booleantryLock()Returns whether the lock was free and has now been taken.booleanvoidunlock()Releases the lock.
-
Method Details
-
lock
void lock()Takes the lock, suspending the caller until it is free. -
lockInterruptibly
Takes the lock, giving up if the caller is interrupted first.- Throws:
InterruptedException- if the caller was interrupted
-
tryLock
boolean tryLock()Returns whether the lock was free and has now been taken.- Returns:
- whether the lock was free and has now been taken
-
tryLock
- Parameters:
time- the longest to waitunit- the unit oftime- Returns:
- whether the lock was taken in time
- Throws:
InterruptedException- if the caller was interrupted
-
unlock
void unlock()Releases the lock. -
newCondition
Condition newCondition()Returns a condition bound to this lock.- Returns:
- a condition bound to this lock
-