update the example code

This commit is contained in:
Andy Pan 2018-05-20 23:26:15 +08:00
parent f0c48f295b
commit 6f6a14b29e
1 changed files with 21 additions and 7 deletions

View File

@ -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!")
//}