MCPcopy
hub / github.com/mao888/golang-guide / add

Function add

golang/go-study/go语言基础/并发/并发安全和锁/数据竞争示例.go:12–17  ·  view source on GitHub ↗

add 对全局变量x执行5000次加1操作

()

Source from the content-addressed store, hash-verified

10
11// add 对全局变量x执行5000次加1操作
12func add() {
13 for i := 0; i < 5000; i++ {
14 x += 1
15 }
16 wg.Done()
17}
18
19func main() {
20 wg.Add(2)

Callers 1

mainFunction · 0.70

Calls 1

DoneMethod · 0.80

Tested by

no test coverage detected