mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 04:37:49 +08:00
31 lines
480 B
Go
31 lines
480 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/gogf/gf/os/grpool"
|
|
"github.com/gogf/gf/os/gtimer"
|
|
)
|
|
|
|
func job() {
|
|
time.Sleep(1 * time.Second)
|
|
}
|
|
|
|
func main() {
|
|
pool := grpool.New(100)
|
|
for i := 0; i < 1000; i++ {
|
|
pool.Add(job)
|
|
}
|
|
fmt.Println("worker:", pool.Size())
|
|
fmt.Println(" jobs:", pool.Jobs())
|
|
gtimer.SetInterval(time.Second, func() {
|
|
fmt.Println("worker:", pool.Size())
|
|
fmt.Println(" jobs:", pool.Jobs())
|
|
fmt.Println()
|
|
gtimer.Exit()
|
|
})
|
|
|
|
select {}
|
|
}
|