Permalink
Browse files

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.
  • Loading branch information...
bgrozev committed Feb 8, 2019
1 parent e3e78dc commit e87d331e5798b0a85108ea0fd712b1c9e4200ea9
@@ -57,9 +57,7 @@
* {@link NetAccessManager}s.
*/
private static ExecutorService messageProcessingExecutor
= ExecutorFactory.createFixedThreadPool(
Runtime.getRuntime().availableProcessors(),
"ice4j.NetAccessManager-");
= ExecutorFactory.createCachedThreadPool("ice4j.NetAccessManager-");

/**
* Maximum number of {@link MessageProcessingTask} to keep in object pool.
@@ -112,7 +112,7 @@ private static ScheduledExecutorService createScheduledExecutor(
executor.setKeepAliveTime(threadKeepAliveTime, timeUnit);
executor.allowCoreThreadTimeOut(true);
executor.setRemoveOnCancelPolicy(true);
return Executors.unconfigurableScheduledExecutorService(executor);
return executor;
}

/**
@@ -135,6 +135,22 @@ public static ExecutorService createFixedThreadPool(
new LinkedBlockingDeque<>(), threadFactory);
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);
}
}

0 comments on commit e87d331

Please sign in to comment.