Junior — Senior
Sequence of output from goroutines
livecode
Task condition
Determine which lines will be printed and in what order.
func main() {
runtime.GOMAXPROCS(1)
var wgCounter sync.WaitGroup
wgCounter.Add(1)
go func() {
time.Sleep(time.Second * 2)
fmt.Println("1")
wgCounter.Done()
}()
go func() {
fmt.Println("2")
}()
wgCounter.Wait()
fmt.Println("3")
}