IT lexicon › Programming › Happens-before edge

Happens-before edge

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

A specific ordering rule between two operations in the memory model, the foundation of concurrency guarantees.

Happens-before edges form the basis of all thread-safety guarantees. An edge from A to B ensures all memory effects of A are visible before B starts. The Java Memory Model and C++ standard define powerful edges: unlock→lock, volatile write→volatile read, thread start, thread join. These prevent optimizations but guarantee that properly synchronized programs are free of data races. Without them, compilers and CPUs could legally reorder operations in ways that corrupt concurrent code.

← Back to the lexicon