// example.go

package main

var gMap = make(map[int]int)

func w() {
    temp := make(map[int]int)
    temp[1] = 100
    temp[2] = 200
    gMap = temp    // Does the compiler or cpu will reorder temp[1]=100, 
temp[2]=200, gMap=temp ??
}

func r() {
    local := gMap
    println(local[1], local[2])
}

func main() {

    go w()
    go r()

    // ...
}

I have one goroutine to read the map and one goroutine to rewrite the 
global map variable does this safe ??




-- 
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.

Reply via email to