How to wait for all threads to finish, using ExecutorService?
I need to execute some amount of tasks 4 at a time, something like this: ExecutorService taskExecutor = Executors.newFixedThreadPool(4); while(…) { taskExecutor.execute(new MyTask()); } //…wait for completion somehow How can I get notified once all of them are complete? For now I can’t think about anything better than setting some global task counter and decrease … Read more