Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
hub
/
github.com/mao888/golang-guide
/ main
Function
main
golang/go-study/go语言基础/并发/并发安全和锁/数据竞争示例.go:19–27 ·
view source on GitHub ↗
()
Source
from the content-addressed store, hash-verified
17
}
18
19
func
main() {
20
wg.Add(2)
21
//runtime.GOMAXPROCS(1)
22
go
add()
23
go
add()
24
25
wg.Wait()
26
fmt.Println(x)
27
}
28
29
/*
30
开启了两个 goroutine 分别执行 add 函数,
Callers
nothing calls this directly
Calls
3
add
Function · 0.70
Add
Method · 0.45
Wait
Method · 0.45
Tested by
no test coverage detected