Index: src/openmap/com/bbn/openmap/util/TaskService.java =================================================================== --- src/openmap/com/bbn/openmap/util/TaskService.java (revision 2164) +++ src/openmap/com/bbn/openmap/util/TaskService.java (working copy) @@ -26,9 +26,7 @@ public static void initialize(PropertyHandler properties) { synchronized (TaskService.class) { - if (singleton != null) { - throw new RuntimeException("Thread pool has already been initialized."); - } + TaskService old = singleton; Properties openmapProperties = properties.getProperties(Environment.OpenMapPrefix); String poolSizeString = openmapProperties.getProperty(Environment.ThreadPool); int poolSize; @@ -37,7 +35,16 @@ } else { poolSize = DEFAULT_POOL_SIZE; } - singleton = new TaskService(poolSize); + + if ((old == null) || (old.poolSize != poolSize)) { + singleton = new TaskService(poolSize); + + // shut down the old executor + if (old != null) { + old.executor.shutdown(); + } + } + } } @@ -54,9 +61,11 @@ } private final ExecutorService executor; + private final int poolSize; private TaskService(int poolSize) { executor = Executors.newFixedThreadPool(poolSize); + this.poolSize = poolSize; } /**