go sync.WaitGroup
package main
import (
"fmt"
"sync"
)
func say(i int ,wg *sync.WaitGroup) {
defer wg.Done()
fmt.Println(i)
}
func main() {
var wg sync.WaitGroup
for i:=0;i<1000;i++{
wg.Add(1)
go say(i,&wg)
}
fmt.Println(4444444)
wg.Wait()
}
package main
import (
"fmt"
"sync"
)
func say(i int ,wg *sync.WaitGroup) {
defer wg.Done()
fmt.Println(i)
}
func main() {
var wg sync.WaitGroup
for i:=0;i<1000;i++{
wg.Add(1)
go say(i,&wg)
}
fmt.Println(4444444)
wg.Wait()
}