Skip to content

Commit e954908

Browse files
authored
bug: hold the lock when spawning a new worker (#376)
Fixes #374
1 parent a0e137a commit e954908

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,9 @@ retry:
472472
// If the worker queue is empty, and we don't run out of the pool capacity,
473473
// then just spawn a new worker goroutine.
474474
if capacity := p.Cap(); capacity == -1 || capacity > p.Running() {
475-
p.lock.Unlock()
476475
w = p.workerCache.Get().(worker)
477476
w.run()
477+
p.lock.Unlock()
478478
return
479479
}
480480

0 commit comments

Comments
 (0)