Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardGosync/atomic and memory orderingSingle-choice MCQ

This loop spins on a flag updated by another goroutine using a non-atomic plain bool. Aside from being a data race, why might the loop never terminate even on hardware with coherent caches?

var stop bool func main() { go func() { time.Sleep(time.Millisecond) stop = true }() for !stop { } }