I would like to perform the following algorithm - this must be done in Java
for(int i = 0; i< 100; i++){
create 8 threads which perform a task
wait for all threads to finish
}
It is desirable that threads are not continuously created and destroyed due to overheads (and the fact that each thread will have <20milli seconds of work), which brought about the idea of Thread Pools1. I also know that using Executable2, one can call shutdown, and then awaitTermination. However it is not desirable in this case due to the loop. Thus how can thread synchronization occur?
I would like to synchronize threads in the thread pool as would be done using a traditional thread's join() method.