awesome-patterns/concurrency/waitgroup/main.go
2017-12-14 22:26:43 +10:00

29 lines
280 B
Go

package main
import (
"fmt"
"sync"
)
var wg sync.WaitGroup
func main() {
for i := 0; i <= 10; i++ {
go print(i)
wg.Add(1)
}
wg.Wait()
}
func looprint(count int) {
for i := 0; i <= count; i++ {
fmt.Println(i)
}
}
func print(i int) {
fmt.Println(i)
wg.Done()
}