package main import "fmt" import "sync" import "time" var oc sync.Once var a int = 5; func main() { go func(){ oc.Do(func(){ a++ }) }() go func(){ oc.Do(func(){ a++ }) }() time.Sleep(time.Second) fmt.Println(a) }
标签:oc,sync,func,time,go,import,Once From: https://www.cnblogs.com/angdh/p/16795475.html