I need to execute some amount of tasks 4 at a time, something like this:
ExecutorService taskExecutor = Executors.newFixedThreadPool(4); while(...) { tas
ExecutorService.invokeAll() does it for you.
ExecutorService taskExecutor = Executors.newFixedThreadPool(4); List> tasks; // your tasks // invokeAll() returns when all tasks are complete List> futures = taskExecutor.invokeAll(tasks);