bugfix worker-pools
This commit is contained in:
parent
76658c8a06
commit
e83d66772e
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
// Here's the worker, of which we'll run several
|
// Here's the worker, of which we'll run several
|
||||||
@ -12,7 +13,7 @@ import "time"
|
|||||||
// simulate an expensive task.
|
// simulate an expensive task.
|
||||||
func worker(id int, jobs <-chan int, results chan<- int) {
|
func worker(id int, jobs <-chan int, results chan<- int) {
|
||||||
for j := range jobs {
|
for j := range jobs {
|
||||||
println("worker", id, "processing job", j)
|
fmt.Println("worker", id, "processing job", j)
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
results <- j * 2
|
results <- j * 2
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user