func main() {
	const numJobs = 5
	const numWorkers = 3
	jobs := make(chan int, numJobs)
	results := make(chan int, numJobs)

	for w := 0; w < numWorkers; w++ {
		go worker(w, jobs, results)
	}

	for j := 0; j < numJobs; j++ {
		jobs <- j
	}
	close(jobs)

	log.Println("Results:")
	for r := 0; r < numJobs; r++ {
		fmt.Println(<-results)
	}
}
// time go run worker_pool.go
time go run worker_pool.go
// time go run worker_pool . go
func main() {
	const numJobs = 5
	const numWorkers = 3
	jobs := make(chan int, numJobs)
	results := make(chan int, numJobs)
	for w := 0; w < numWorkers; w++ {
		go worker(w, jobs, results)
	}
	for j := 0; j < numJobs; j++ {
		jobs <- j
	}
	close(jobs)
	log.Println("Results:")
	for r := 0; r < numJobs; r++ {
		fmt.Println(<-results)
	}
}
func main ( ) { const numJobs = 5 const numWorkers = 3 jobs := make ( chan int , numJobs ) results := make ( chan int , numJobs ) for w := 0 ; w < numWorkers ; w ++ { go worker ( w , jobs , results ) } for j := 0 ; j < numJobs ; j ++ { jobs <- j } close ( jobs ) log . Println ( " " ) for r := 0 ; r < numJobs ; r ++ { fmt . Println ( <- results ) } }
time go run worker_pool.go
time go run worker_pool . go