sclass ConcurrentEvaluator { new L functions; L results = synchroList(); ExecutorService executorService; O onNewResult; // Runnable or voidfunc(int) volatile bool cancelled; void add(O f) { functions.add(f); } void start() { executorService = Executors.newFixedThreadPool(coresToUse()); while (l(results) < l(functions)) results.add(null); for _i over functions: { final int i = _i; executorService.execute(r { results.set(i, pcallF(functions.get(i))); onNewResult(i); }); } } void onNewResult(int i) { if (!cancelled) pcallF(onNewResult, i); } L results() { ret cloneList(results); } void cancel { cancelled = true; executorService.shutdownNow(); } }