jargon

Backend & systems·Concurrency and coordination

you wrap the shared counter in a lock so only one thread can be inside that block at a time.

Mutex

Also calledmutual exclusion, critical section, lock

A primitive guaranteeing that only one thread executes a protected region at once. It is the simplest correct answer to shared mutable state and the easiest way to serialise your whole application by accident. Hold it for as little code as possible, and never across I/O.

Commonly confused with