golang中的错误fatal error: concurrent map writes
具体的代码如下:
package main
import (
"fmt"
"time"
)
var m = make(map[int]int, 10)
func solution(n int){
res := 1
for i:=1; i<=n; i++{
res = res * i
}
m[n] = res
}
func main(){
for i:=1; i<=200; i++{
go solution(i)
}
time.Sleep(time.Second*10)
for ind, val := range m{
fmt.Printf("[%d] = %d /n", ind, val)
}
}
出现如下的错误:
fatal error: concurrent map writes
fatal error: concurrent map writes
golang中的错误fatal error: concurrent map writes最先出现在Python成神之路。
共有 0 条评论