On Mon, Jul 10, 2017 at 2:24 PM T L <tapir....@gmail.com> wrote: > Aha, what I wanted to express is the execution orders of the two lines may be randomized. > > atomic.AddInt32(&x, 1) > atomic.AddInt32(&y, 1)
No, assuming those two lines are as written, ie. part of single function and thus executed in a single/the same goroutine. Then the memory model guarantees they are executed in order, ie. x will be updated before y. But there's no such guarantee when the same variable x and y are observed in a different, concurrently executing goroutine. To establish such ordering you have to synchronize, only that gives you the H-B relation within the synchronization participants. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.