On Mon, Nov 7, 2016 at 12:57 AM, <ayr...@gmail.com> wrote: > All above discussion is talking about cpu excution order or memory order, > lets make it easy and clear. > If I use a mutex when create a temporary map to guarantee that this > temporary map has been successully created, modified and set to gMap1. > Is it safe setting gMap1 pointer to gMap pointer when reading data from > gMap? > In my opinion, It is safe to set a pointer while another goroutine is > reading this pointer.
That is a race condition according to the rules of the language (https://golang.org/ref/mem). Don't do it. I can't think of a reason why it would fail in practice on current processors, but perhaps someone else will. Ian -- 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.