how do you know when an executer service is done
ExecutorService executorService = Executors.newFixedThreadPool(10);
executorService.submit(() -> {
int linesRead = 0;
while (linesRead < 1000000) {
System.out.println(linesRead);
linesRead++;
}
System.out.println("lines read: " + linesRead);
executorService.shutdown();
});
//sleep until executerService has shut itself down
while(executorService.isTerminated() == false) {
TimeUnit.MILLISECONDS.sleep(10);
}
Just have the executorService shut it's self down when it's done and
loop in the main thread until it's done.