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

Two goroutines run with no synchronization. Goroutine A does `x = 1; done = true`. Goroutine B loops `for !done {}` then reads `x`. Under the Go memory model, what is true about B observing `x == 0` after seeing `done == true`?

var x, done int // A: x = 1 done = true // B: for done == 0 { } print(x)