Example for sync.WaitGroup correct?
问题 Is this example usage of sync.WaitGroup correct? It gives the expected result, but I am unsure about the wg.Add(4) and the position of wg.Done() . Does it make sense to add the four goroutines at once with wg.Add() ? http://play.golang.org/p/ecvYHiie0P package main import ( \"fmt\" \"sync\" \"time\" ) func dosomething(millisecs time.Duration, wg *sync.WaitGroup) { duration := millisecs * time.Millisecond time.Sleep(duration) fmt.Println(\"Function in background, duration:\", duration) wg.Done