Worker Pool
Worker Pool
Section titled “Worker Pool”Implement a worker pool pattern to process multiple jobs concurrently.
Recommended Prerequisites
Complete these exercises first for the best learning experience:
- ○Goroutine Counter
- ○Channel Ping-Pong
0/2 completed
Background
Section titled “Background”The worker pool pattern is essential for controlling concurrency. Instead of spawning unlimited goroutines, you create a fixed number of workers that process jobs from a queue.
Your Task
Section titled “Your Task”Implement a worker pool that:
- Creates a configurable number of workers
- Processes jobs from a shared channel
- Each job is a number that should be squared
- Collects results and prints them
Worker Pool
~20 minmedium
Implement a pool of workers processing jobs concurrently
Key Concepts
Section titled “Key Concepts”- Worker pool pattern: Fixed number of workers processing from a queue
- Buffered channels: Using buffer to decouple producers and consumers
- WaitGroup: Waiting for multiple goroutines to complete
- Channel closing: Signaling no more values will be sent