Skip to content

Instantly share code, notes, and snippets.

@quasilyte
Created November 8, 2018 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quasilyte/3526f63bd474bafc1578c2ccae22930f to your computer and use it in GitHub Desktop.
Save quasilyte/3526f63bd474bafc1578c2ccae22930f to your computer and use it in GitHub Desktop.
package main
import "sync"
// Запустите с помощью "go run -race datarace.go".
var globalX int
func main() {
var wg sync.WaitGroup
wg.Add(10)
for i := 0; i < 10; i++ {
go func() {
for i := 0; i < 1000000; i++ {
globalX++
}
wg.Done()
}()
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment