Skip to content

Instantly share code, notes, and snippets.

@mvrilo
Created September 7, 2013 18:46
Show Gist options
  • Save mvrilo/6478135 to your computer and use it in GitHub Desktop.
Save mvrilo/6478135 to your computer and use it in GitHub Desktop.
package main
import (
"sync"
"time"
)
func main() {
wg := new(sync.WaitGroup)
for _, i := range []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} {
wg.Add(1)
go func(j int) {
time.Sleep(time.Second * 1)
println(j)
wg.Done()
}(i)
if i%2 == 0 {
wg.Wait()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment