Created
September 7, 2013 18:46
-
-
Save mvrilo/6478135 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" | |
"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