fix: Changes the fixed thread pool in NetAccessManager to an unbounde… (#171)
* fix: Changes the fixed thread pool in NetAccessManager to an unbounded cached thread pool.
This commit is contained in:
parent
e3e78dcda3
commit
e87d331e57
@ -57,9 +57,7 @@ class NetAccessManager
|
|||||||
* {@link NetAccessManager}s.
|
* {@link NetAccessManager}s.
|
||||||
*/
|
*/
|
||||||
private static ExecutorService messageProcessingExecutor
|
private static ExecutorService messageProcessingExecutor
|
||||||
= ExecutorFactory.createFixedThreadPool(
|
= ExecutorFactory.createCachedThreadPool("ice4j.NetAccessManager-");
|
||||||
Runtime.getRuntime().availableProcessors(),
|
|
||||||
"ice4j.NetAccessManager-");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of {@link MessageProcessingTask} to keep in object pool.
|
* Maximum number of {@link MessageProcessingTask} to keep in object pool.
|
||||||
|
|||||||
@ -112,7 +112,7 @@ public class ExecutorFactory
|
|||||||
executor.setKeepAliveTime(threadKeepAliveTime, timeUnit);
|
executor.setKeepAliveTime(threadKeepAliveTime, timeUnit);
|
||||||
executor.allowCoreThreadTimeOut(true);
|
executor.allowCoreThreadTimeOut(true);
|
||||||
executor.setRemoveOnCancelPolicy(true);
|
executor.setRemoveOnCancelPolicy(true);
|
||||||
return Executors.unconfigurableScheduledExecutorService(executor);
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,6 +135,22 @@ public class ExecutorFactory
|
|||||||
new LinkedBlockingDeque<>(), threadFactory);
|
new LinkedBlockingDeque<>(), threadFactory);
|
||||||
executor.allowCoreThreadTimeOut(true);
|
executor.allowCoreThreadTimeOut(true);
|
||||||
|
|
||||||
return Executors.unconfigurableExecutorService(executor);
|
return executor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an {@link ExecutorService} with an unlimited number of threads
|
||||||
|
* which are released after idle timeout.
|
||||||
|
*
|
||||||
|
* @param threadNamePrefix - name prefix for threads created by pool
|
||||||
|
* @return pre-configured {@link ExecutorService}
|
||||||
|
*/
|
||||||
|
public static ExecutorService createCachedThreadPool(
|
||||||
|
String threadNamePrefix)
|
||||||
|
{
|
||||||
|
final CustomizableThreadFactory threadFactory
|
||||||
|
= new CustomizableThreadFactory(threadNamePrefix, true);
|
||||||
|
|
||||||
|
return Executors.newCachedThreadPool(threadFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user