IT lexicon › Programming › Coarse-grained locking

Coarse-grained locking

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

Protecting an entire data structure or subsystem with a single mutex for simplicity, at the cost of reduced parallelism.

The simplest way to make something thread-safe is wrapping it in one mutex. All operations wait on the same lock, limiting concurrency and creating a bottleneck. But reasoning is straightforward and deadlock is avoided. Often the right starting point: start coarse-grained, measure, and refactor to fine-grained locking only if profiling shows contention. Many systems never need the extra complexity; a single lock is "good enough" if threads don't pile up waiting for it.

← Back to the lexicon