Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "sync"
- func main() {
- for {
- x := 0
- y := 0
- a := 0
- b := 0
- var wg sync.WaitGroup
- wg.Add(1)
- go func() {
- y = 1
- a = x
- wg.Done()
- }()
- wg.Add(1)
- go func() {
- x = 1
- b = y
- wg.Done()
- }()
- wg.Wait()
- if a == 0 && b == 0 {
- println("Hello world!")
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement