Interface MultiLock
- All Known Implementing Classes:
PreciseMultiLock
public interface MultiLock
Provides nonreenterant locking capability for a given ID. This class behaves similar to having an array of locks and
locking/unlocking array elements but is light-weight.
WARNING: These locks are not reenterant. If a thread locks the same ID multiple times it will wait forever.
- Author:
- Evren Sirin
-
Method Summary
-
Method Details
-
lock
void lock(int lockID) Locks the given ID, waiting indefinitely if another thread already has a lock. -
tryLock
boolean tryLock(int lockID) Tries to lock the given ID if it is possible to do so immediately and returntrue. If the lock is already held by another thread, this function immediately returnsfalse. Since this class does not provide reentarant behavior, this function will returnfalseeven if it is the same thread that holds the lock before this function call. -
unlock
Unlocks the given ID. There is no requirement that a thread that unlocks an ID must have locked that ID by callinglock(int).- Throws:
IllegalArgumentException
-