Why is atomic.StoreUint32 preferred over a normal assignment in sync.Once?
问题 While reading the source codes of Go, I have a question about the code in src/sync/once.go: func (o *Once) Do(f func()) { // Note: Here is an incorrect implementation of Do: // // if atomic.CompareAndSwapUint32(&o.done, 0, 1) { // f() // } // // Do guarantees that when it returns, f has finished. // This implementation would not implement that guarantee: // given two simultaneous calls, the winner of the cas would // call f, and the second would return immediately, without // waiting for the