Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardKotlinJVM memory model happens-beforeSingle-choice MCQ

Why is the JMM 'happens-before' relation insufficient on its own to forbid all surprising results, requiring the additional out-of-thin-air / causality rules?

// Initially x == y == 0, both plain fields // Thread 1: r1 = x; y = r1 // Thread 2: r2 = y; x = r2