Created
November 8, 2018 14:09
-
-
Save quasilyte/3526f63bd474bafc1578c2ccae22930f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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