


Release relinquishes ownership of the lock, allowing another thread to take ownership of it. If a thread tries to acquire a lock currently owned by another thread, it blocks until the other thread releases the lock.Īt that point, it will contend with any other threads that are trying to acquire the lock.Īt most one thread can own the lock at a time. Holding a lock is how one thread tells other threads: “I’m changing this thing, don’t touch it right now.”Īcquire allows a thread to take ownership of a lock. Since race conditions caused by concurrent manipulation of shared mutable data are disastrous bugs - hard to discover, hard to reproduce, hard to debug - we need a way for concurrent modules that share memory to synchronize with each other.Ī lock is an abstraction that allows at most one thread to own it at a time. The correctness of a concurrent program should not depend on accidents of timing.
