Critical region
A code section whose access must be restricted so that only one thread at a time executes the code.
A critical region protects invariants by ensuring threads don't read or write half-finished data simultaneously. Protection can be implemented with mutexes (locking), monitor objects, or lock-free atomic operations. The smaller and less frequently a critical region executes, the less lock contention occurs. A well-designed parallel application minimizes both the size and duration of critical regions—too much locking becomes the bottleneck, and too little is buggy.