mirror of
https://gitee.com/johng/gf.git
synced 2024-12-05 05:37:55 +08:00
23 lines
249 B
Go
23 lines
249 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
|
|
"github.com/gogf/gf/os/grpool"
|
|
)
|
|
|
|
func main() {
|
|
p := grpool.New(1)
|
|
wg := sync.WaitGroup{}
|
|
for i := 0; i < 10; i++ {
|
|
wg.Add(1)
|
|
v := i
|
|
p.Add(func() {
|
|
fmt.Println(v)
|
|
wg.Done()
|
|
})
|
|
}
|
|
wg.Wait()
|
|
}
|