Fixed #1796 - ReservedThreadExecutor defaulting to capacity=1 only.

Using getMaxThreads() instead of getThreads().
This commit is contained in:
Simone Bordet 2017-09-07 15:37:49 +02:00
parent fb86b8e54f
commit ec9a4ecdc1
1 changed files with 6 additions and 6 deletions

View File

@ -60,15 +60,15 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements Executo
if (capacity < 0)
{
if (executor instanceof ThreadPool)
int cpus = Runtime.getRuntime().availableProcessors();
if (executor instanceof ThreadPool.SizedThreadPool)
{
int threads = ((ThreadPool)executor).getThreads();
int cpus = Runtime.getRuntime().availableProcessors();
capacity = Math.max(1,Math.min(cpus,threads/8));
int threads = ((ThreadPool.SizedThreadPool)executor).getMaxThreads();
capacity = Math.max(1, Math.min(cpus, threads / 8));
}
else
{
capacity = Runtime.getRuntime().availableProcessors();
capacity = cpus;
}
}