IDEMPIERE-502 Use single thread pool for client and server process. Fixed scheduled thread pool executor service doesn't use min pool size and shouldn't have core thread timeout.

This commit is contained in:
Heng Sin Low 2012-12-03 14:37:46 +08:00
parent 41249300e7
commit db154e11b7
1 changed files with 1 additions and 18 deletions

View File

@ -554,37 +554,20 @@ public final class Adempiere
private static void createThreadPool() { private static void createThreadPool() {
int max = Runtime.getRuntime().availableProcessors() * 20; int max = Runtime.getRuntime().availableProcessors() * 20;
int min = max / 2;
int defaultMax = max; int defaultMax = max;
int defaultMin = min;
Properties properties = Ini.getProperties(); Properties properties = Ini.getProperties();
String maxSize = properties.getProperty("MaxThreadPoolSize"); String maxSize = properties.getProperty("MaxThreadPoolSize");
String minSize = properties.getProperty("MinThreadPoolSize");
if (maxSize != null) { if (maxSize != null) {
try { try {
max = Integer.parseInt(maxSize); max = Integer.parseInt(maxSize);
} catch (Exception e) {} } catch (Exception e) {}
} }
if (minSize != null) {
try {
min = Integer.parseInt(minSize);
} catch (Exception e) {}
}
if (max < min) {
max = min;
}
if (max <= 0) { if (max <= 0) {
max = defaultMax; max = defaultMax;
} }
if (min < 0) {
min = defaultMin;
}
// start thread pool // start thread pool
threadPoolExecutor = new ScheduledThreadPoolExecutor(min); threadPoolExecutor = new ScheduledThreadPoolExecutor(max);
threadPoolExecutor.setMaximumPoolSize(max);
threadPoolExecutor.setKeepAliveTime(10, TimeUnit.MINUTES);
threadPoolExecutor.allowCoreThreadTimeOut(true);
Trx.startTrxMonitor(); Trx.startTrxMonitor();
} }