Fixed #1796 - ReservedThreadExecutor defaulting to capacity=1 only.
Using getMaxThreads() instead of getThreads().
This commit is contained in:
parent
fb86b8e54f
commit
ec9a4ecdc1
|
@ -57,18 +57,18 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements Executo
|
||||||
public ReservedThreadExecutor(Executor executor,int capacity)
|
public ReservedThreadExecutor(Executor executor,int capacity)
|
||||||
{
|
{
|
||||||
_executor = executor;
|
_executor = executor;
|
||||||
|
|
||||||
if (capacity < 0)
|
if (capacity < 0)
|
||||||
{
|
{
|
||||||
if (executor instanceof ThreadPool)
|
int cpus = Runtime.getRuntime().availableProcessors();
|
||||||
|
if (executor instanceof ThreadPool.SizedThreadPool)
|
||||||
{
|
{
|
||||||
int threads = ((ThreadPool)executor).getThreads();
|
int threads = ((ThreadPool.SizedThreadPool)executor).getMaxThreads();
|
||||||
int cpus = Runtime.getRuntime().availableProcessors();
|
capacity = Math.max(1, Math.min(cpus, threads / 8));
|
||||||
capacity = Math.max(1,Math.min(cpus,threads/8));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
capacity = Runtime.getRuntime().availableProcessors();
|
capacity = cpus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue