Don't kick off all goroutines at once
This commit is contained in:
parent
c0a215f2bb
commit
60c49f9f7d
2
main.go
2
main.go
@ -40,9 +40,9 @@ func main() {
|
|||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
sema := make(chan bool, *conc)
|
sema := make(chan bool, *conc)
|
||||||
for w := range work {
|
for w := range work {
|
||||||
|
sema <- true
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(j job) {
|
go func(j job) {
|
||||||
sema <- true
|
|
||||||
defer func() {
|
defer func() {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
<-sema
|
<-sema
|
||||||
|
Loading…
Reference in New Issue
Block a user