Update BoundedExecutorServiceImpl.java

This commit is contained in:
Andrea Cavalli 2020-05-26 12:51:08 +02:00
parent c852ce4c2b
commit cd543cad94

View File

@ -64,14 +64,16 @@ class BoundedExecutorServiceImpl extends ThreadPoolExecutor implements BoundedEx
} }
} }
semaphore.acquire(); semaphore.acquire();
var queueSize = getQueue().size();
synchronized (queueSizeStatusLock) {
if (queueSizeStatus != null) queueSizeStatus.accept(queueSize >= maxQueueSize, queueSize);
}
} }
@Override @Override
public void beforeExecute(Thread t, Runnable r) { public void beforeExecute(Thread t, Runnable r) {
var queueSize = getQueue().size();
synchronized (queueSizeStatusLock) {
if (queueSizeStatus != null) queueSizeStatus.accept(queueSize >= maxQueueSize, queueSize);
}
semaphore.release(); semaphore.release();
super.beforeExecute(t, r); super.beforeExecute(t, r);