package main import ( "fmt" "sync" ) var a = make(chan bool) var wg sync.WaitGroup func main() { wg.Add(1) go test() for i := 0; i < 2; i++ { wg.Add(1) go test2() } wg.Wait() } func test() { for val := range a { fmt.Println(val) } wg.Done() } func test2() { for i := 0; i < 3; i++ { a <- true } wg.Done() }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)