pulic class SampleCallable implements Callable<Void> { @Override public Void call() throws Exception { something(); return null; } }
List<Callable<Void>> callList = new ArrayList<Callable<Void>>(); SampleCallable call1 = new SampleCallable(); SampleCallable call2 = new SampleCallable(); callList.add(call1); callList.add(call2) ExecutorService executor = Executors.newSingleThreadExecutor(); executor.invokeAll(callList); executor.shutdown();