I am using an
ExecutorService executor = Executors.newFixedThreadPool(4);
to pass Runnable threads for multi-threaded Java and need a barrier where the program waits until all threads that have been submitted to the ThreadPool's queue so far have finished execution. Afterwards I want to continue filling the queue again. This procedure is iterated in a for-loop.
Is there an efficient method, which does not require to always shutdown the ExecutorService and instantiate a new one?