Skip to content

Instantly share code, notes, and snippets.

@hongruiqi
Created November 29, 2015 14:07
Show Gist options
  • Select an option

  • Save hongruiqi/617b97372fa971f31d3a to your computer and use it in GitHub Desktop.

Select an option

Save hongruiqi/617b97372fa971f31d3a to your computer and use it in GitHub Desktop.
funny
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!")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment