diff --git a/pool.go b/pool.go index 9184c24..38fe397 100644 --- a/pool.go +++ b/pool.go @@ -76,9 +76,10 @@ func (p *Pool) monitorAndClear() { n = i w.stop() idleWorkers[i] = nil + p.running-- } if n > 0 { - n += 1 + n++ p.workers = idleWorkers[n:] } p.lock.Unlock() diff --git a/pool_func.go b/pool_func.go index 439b0fe..485ebe1 100644 --- a/pool_func.go +++ b/pool_func.go @@ -77,6 +77,7 @@ func (p *PoolWithFunc) MonitorAndClear() { n = i w.stop() idleWorkers[i] = nil + p.running-- } if n > 0 { n += 1