package main
import (
"fmt"
"sync"
)
func main() {
const gr = 500
var wg sync.WaitGroup
wg.Add(gr * 2)
var n int = 0
for i := 0; i < gr; i++ {
go func() {
n++
wg.Done()
}()
go func() {
n--
wg.Done()
}()
}
wg.Wait()
fmt.Println(n)
}
Why the value of n is different evertime, my for loop is incrementing and decrementing the value of n for same no. time, then why the output is different on each compile