wg sync.WaitGroup wg.Add(nj) done = func() { wg.Done() } dispatch2(nw, nj) wg.Wait() } >$ go test -run dispatch2 finished: worker[2], job[3] finished: worker[1], job[1] finished: worker[3], job[2] finished: worker[3], job[6] finished: worker[2], job[4] finished: worker[3], job[7] finished: worker[2], job[8] finished: worker[2], job[10] finished: worker[1], job[5] finished: worker[3], job[9] PASS ok 0.198s Sentinel act as syncer and counter (with sync.WaitGroup)