IT lexicon › Programming › Block-wait

Block-wait

Programming På svenska → Updated: 2026-11-16

When a thread waits for a locked resource or event and the OS removes it from the runnable queue — the thread consumes no CPU time.

In contrast to busy-waiting (spin loops that actively check a condition), blocking consumes no power and lets other threads run. Mutex.lock() usually blocks until the lock is available. The OS maintains a wait queue: the thread registers, sleeps, and wakes when the lock is released or a signal arrives.

The tradeoff is wake-up latency (OS overhead) and context-switch cost. So high-performance code often uses spin-locks or lock-free structures for very short critical sections. Block-wait is right for long waits; spinning is right when the wait is expected to be brief.

← Back to the lexicon