Lock

You might say

Two requests decrement the last item concurrently. Lock the shared record so one proceeds and the other waits and rechecks.

A lock is a concurrency-control mechanism that limits simultaneous access to a shared resource.When two requests update one inventory record, the lock owner checks and decrements before release; the waiter then rechecks, so only one succeeds. The lock must cover the correct resource. Inconsistent acquisition order can deadlock, and an in-process lock does not automatically protect another service instance.
Know first
Lock
Further reading