Package BSsync
Class Lock
- java.lang.Object
-
- BSsync.Lock
-
public class Lock extends java.lang.Object
A simple non-reentrant mutual exclusion lock. The lock is free upon construction. Each acquire gets the lock, and each release frees it. Releasing a lock that is already free has no effect.This implementation makes no attempt to provide any fairness or ordering guarantees.
- See Also:
Semaphore
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
lock()
Acquire the mutex lock.Condition
newCondition()
Create and return a new condition variable associated with this lock.Condition
newCondition(java.lang.String name)
Create and return a new condition variable associated with this lock.void
unlock()
Release the mutex lock.
-
-
-
Method Detail
-
lock
public void lock()
Acquire the mutex lock. If the mutex is already locked, the calling thread is blocked until the mutex is available.
-
unlock
public void unlock()
Release the mutex lock.
-
newCondition
public Condition newCondition()
Create and return a new condition variable associated with this lock. In normal use, the lock should be one that is used for all synchronization of the object using the Condition. Generally, to prevent nested monitor lockouts, this object should not use any native Java synchronized blocks.
-
newCondition
public Condition newCondition(java.lang.String name)
Create and return a new condition variable associated with this lock. The name is just used for debugging output. In normal use, the lock should be one that is used for all synchronization of the object using the Condition. Generally, to prevent nested monitor lockouts, this object should not use any native Java synchronized blocks.- Parameters:
name
- name of the Condition object.
-
-