mirror of
https://gitee.com/johng/gf
synced 2026-06-30 02:51:56 +08:00
26 lines
396 B
Go
26 lines
396 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/gogf/gf/os/grpool"
|
|
"github.com/gogf/gf/os/gtime"
|
|
)
|
|
|
|
func main() {
|
|
start := gtime.TimestampMilli()
|
|
wg := sync.WaitGroup{}
|
|
for i := 0; i < 100000; i++ {
|
|
wg.Add(1)
|
|
grpool.Add(func() {
|
|
time.Sleep(time.Second)
|
|
wg.Done()
|
|
})
|
|
}
|
|
wg.Wait()
|
|
fmt.Println(grpool.Size())
|
|
fmt.Println("time spent:", gtime.TimestampMilli()-start)
|
|
}
|