Last active
June 8, 2017 16:15
-
-
Save Codefor/937aef583ea625a830a71eceaf455c91 to your computer and use it in GitHub Desktop.
fatal error: concurrent map iteration and map write; fatal error: concurrent map writes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
// "fmt" | |
"time" | |
) | |
func main() { | |
m := map[int]int{} | |
go func() { | |
for i := 0; i < 1000000; i++ { | |
m[i] = i | |
} | |
}() | |
for { | |
for i := 0; i < 1000000; i++ { | |
//for k, _ := range m { | |
// k = k * 2 | |
//} | |
k := len(m) | |
k = k * 2 | |
} | |
} | |
for { | |
time.Sleep(time.Second / 100) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment