From 6f6a14b29ea131882e5f24f26028ed276911b748 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Sun, 20 May 2018 23:26:15 +0800 Subject: [PATCH] update the example code --- examples/main.go | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/examples/main.go b/examples/main.go index 61a2c67..3f65770 100644 --- a/examples/main.go +++ b/examples/main.go @@ -11,17 +11,12 @@ func myFunc() { } func main() { - // runTimes := 10000 - - // set 100 the size of goroutine pool - p, _ := ants.NewPool(100) - var wg sync.WaitGroup - // submit + // submit all your tasks to ants pool for i := 0; i < runTimes; i++ { wg.Add(1) - p.Push(func() { + ants.Push(func() { myFunc() wg.Done() }) @@ -29,3 +24,22 @@ func main() { wg.Wait() fmt.Println("finish all tasks!") } + +//func main() { +// runTimes := 10000 +// +// // set 100 the size of goroutine pool +// p, _ := ants.NewPool(100) +// +// var wg sync.WaitGroup +// // submit +// for i := 0; i < runTimes; i++ { +// wg.Add(1) +// p.Push(func() { +// myFunc() +// wg.Done() +// }) +// } +// wg.Wait() +// fmt.Println("finish all tasks!") +//}