Is there an simple/elegant way to make all threads created by ExecutorService
to wait() ?
My current solution is to add a flag and pause make the threads wait with it like so:
public class task implements Runnable {
static boolean flag;
public void run()
{
while(true){
if(flag){
wait();
}else{
/* do stuff */
.
.
.
}
}
}
}
But in this way I can only make thread wait at the end of an iteration of its task and It's seem to be unnecessarily complicated.