Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
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操作
12
func
add() {
13
for
i := 0; i < 5000; i++ {
14
x += 1
15
}
16
wg.Done()
17
}
18
19
func
main() {
20
wg.Add(2)
Callers
1
main
Function · 0.70
Calls
1
Done
Method · 0.80
Tested by
no test coverage detected