Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGoworker pool patternSingle-choice MCQ

In a classic worker pool, N goroutines read jobs from a channel. The producer closes the jobs channel after sending all work. What is the correct way for workers to know when to stop?

func worker(jobs <-chan int, results chan<- int) { for j := range jobs { results <- j * 2 } }