IT lexicon › Programming › Memory visibility

Memory visibility

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

The guarantee that a write by one thread becomes observable to another thread at a predictable time.

Without synchronization, a write by thread A might sit in its CPU cache and never reach main memory—or thread B might read through a stale cache entry and see an old value. Memory visibility is the contract that this won't happen. The memory model defines different visibility guarantees: sequentially consistent (strict but slow), acquire/release (weaker, faster), or relaxed (CPU-native, hard to use correctly). Memory barriers enforce these guarantees by blocking instruction reordering and flushing caches. Too weak and threads see inconsistent data; too strong and performance tanks.

Example: without visibility, a volatile boolean flag in Java or std::atomic in C++ might never wake a waiting thread on another core.

← Back to the lexicon