problem description
func main() {
n := 0
go func() {
for {
n = n+1
}
}()
for {
fmt.Println(n)
}
}
Why does this situation still lead to competition
func main() {
n := 0
go func() {
for {
n = n+1
}
}()
for {
fmt.Println(n)
}
}
Why does this situation still lead to competition
n uses the same variable
two goroutine operations on the same variable, of course there will be competition
Previous: Css style positioning problem
Next: When Qt5 combobox added item, it was added twice in the list. Does anyone know why?