lock

A marker that gives one worker exclusive access to a resource until it releases it.

In more detail

Locks prevent races but make others wait, and under heavy contention lock waits dominate latency. A per key lock is how single flight lets only one request refill a cache entry.

Related terms

Taught in

References