| 123456789101112131415161718192021 |
- package common
- import (
- "fmt"
- "sync"
- "testing"
- "time"
- )
- func Test_gPool_AddJob(t *testing.T) {
- pool := New(10, true)
- result := sync.Map{}
- for x := 0; x < 1000; x++ {
- pool.AddJob(func(args ...interface{}) {
- result.Store(args[0],nil)
- fmt.Println("run: ", args)
- time.Sleep(time.Second)
- }, x)
- }
- time.Sleep(time.Second * 100)
- }
|