This commit is contained in:
邹宗楠
2023-05-30 09:06:09 +08:00
parent d626fcf12d
commit 4b9c783b9a
3 changed files with 345 additions and 142 deletions

View File

@@ -8,6 +8,7 @@ import (
"strconv"
"strings"
"testing"
"time"
"unicode/utf8"
)
@@ -82,3 +83,24 @@ func TestTen216(t *testing.T) {
fmt.Println(gg)
fmt.Println(kk)
}
func TestNewPool(t *testing.T) {
var pool = NewPool(100)
pool.Start()
for i := 0; i < 10; i++ {
num := i
pool.AddJob(func() {
fmt.Printf("Worker %d: %d is odd? %v\n", num%5, num, num%2 == 1)
})
}
time.Sleep(5 * time.Second)
for i := 0; i < 10; i++ {
pool.AddJob(func() {
fmt.Println("刘磊")
})
}
pool.Wait()
pool.Stop()
}