mirror of
https://gitee.com/johng/gf.git
synced 2024-12-05 05:37:55 +08:00
24 lines
396 B
Go
24 lines
396 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
"time"
|
|
"gitee.com/johng/gf/g/os/gtime"
|
|
)
|
|
|
|
|
|
func main() {
|
|
start := gtime.Millisecond()
|
|
wg := sync.WaitGroup{}
|
|
for i := 0; i < 100000; i++ {
|
|
wg.Add(1)
|
|
go func() {
|
|
time.Sleep(time.Second)
|
|
wg.Done()
|
|
}()
|
|
}
|
|
wg.Wait()
|
|
fmt.Println("time spent:", gtime.Millisecond() - start)
|
|
}
|