Library / Concurrency / Synchronisation / Lock
Lock
Kernel mutual-exclusion primitive.
Constructors 1
INIT()Methods 3
MODIFY METHOD acquire() RETURNS voidmodifies
Block until the lock is acquired. Used directly by ThreadCondition (and similar primitives that need explicit acquire/release pairing); everywhere else, prefer the SYNCHRONIZED block which guarantees release on every exit path.
MODIFY METHOD release() RETURNS voidmodifies
Release the lock. Pairs with a previous acquire() on the same Lock from the same thread. Calling release() without first holding the lock is undefined behaviour at the OS level — pthread does not require the implementation to detect or report this misuse.
MODIFY METHOD tryAcquire() RETURNS booleanmodifies
Non-blocking attempt to acquire the lock. Returns TRUE if the caller now holds the lock (and is responsible for calling release() exactly once); FALSE if another thread currently holds it. Useful for optimistic-locking patterns where the caller would rather bail than wait.