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

Two goroutines run concurrently with no other synchronization. What is true about the result printed?

var a, b int32 // goroutine 1 atomic.StoreInt32(&a, 1) r1 := atomic.LoadInt32(&b) // goroutine 2 atomic.StoreInt32(&b, 1) r2 := atomic.LoadInt32(&a) // after both finish fmt.Println(r1, r2)