1
This commit is contained in:
@@ -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()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user