You can reuse the artist service if you change the structure of your code a little.
Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>(16); for (Model m : models) { tasks.add(m.simulationTask()); } ExecutorService executor = Executors.newFixedThreadPool(nThread); try { executor.invokeAll(tasks); } catch(InterruptedException ie) {
Basically, you collect all your tasks, complete them, and wait for them to complete before continuing. Of course, you can also use the new Executor service for each of your time steps, but at least you have options.
Caveats : I did not compile the code so that there might be errors. I also suggested the Integer parameter type for convenience.
source share