Hacker News new | ask | show | jobs
by dragontamer 1295 days ago
Well, that's what Java's "volatile" actually enforces.

C's "volatile" isn't enough, but more recent C compilers have atomics and memory models.

The memory-model problem wasn't solved until the 00s (that late!!!) when multicore CPUs became more commonplace. Java, C++11, and other language / language updates after that point quickly adopted memory models. And the rest is history.

So yeah, use atomics + memory barriers.