- private final static ExecutorService executor = Executors.newFixedThreadPool(
- SwingPreferences.getMaxThreadCount());
+ /**
+ * A single ThreadPoolExecutor that will be used for all simulations.
+ * This executor must not be shut down.
+ */
+ private static final ThreadPoolExecutor executor;
+ static {
+ int n = SwingPreferences.getMaxThreadCount();
+ executor = new ThreadPoolExecutor(n, n,
+ 0L, TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<Runnable>(),
+ new ThreadFactory() {
+ private ThreadFactory factory = Executors.defaultThreadFactory();
+
+ @Override
+ public Thread newThread(Runnable r) {
+ Thread t = factory.newThread(r);
+ t.setDaemon(true);
+ return t;
+ }
+ });
+ }
+