IT lexicon › Programming › Fine-grained locking

Fine-grained locking

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

Strategy of holding many small locks instead of one global lock, reducing contention and enabling parallelism.

A single mutex protecting an entire data structure forces all threads to serialize. Fine-grained locking partitions the lock—one per bucket in a hash table, one per tree node. Threads can then work on different pieces in parallel. The cost: complexity and risk of deadlock if lock ordering isn't carefully planned. Java's concurrent collections (ConcurrentHashMap) use fine-grained locking; older `Collections.synchronizedMap` uses a single lock and scales poorly.

← Back to the lexicon