26 lines
414 B
Go
26 lines
414 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/alitto/pond"
|
|
)
|
|
|
|
func main() {
|
|
|
|
// Create an unbuffered (blocking) pool with a fixed
|
|
// number of workers
|
|
pool := pond.New(10, 0, pond.MinWorkers(10))
|
|
|
|
// Submit 1000 tasks
|
|
for i := 0; i < 1000; i++ {
|
|
n := i
|
|
pool.Submit(func() {
|
|
fmt.Printf("Running task #%d\n", n)
|
|
})
|
|
}
|
|
|
|
// Stop the pool and wait for all submitted tasks to complete
|
|
pool.StopAndWait()
|
|
}
|