Skip to content

Instantly share code, notes, and snippets.

@cnmoro
Created May 24, 2019 00:50
Show Gist options
  • Save cnmoro/be4aaccb6da479e22867c5eab5c2eae3 to your computer and use it in GitHub Desktop.
Save cnmoro/be4aaccb6da479e22867c5eab5c2eae3 to your computer and use it in GitHub Desktop.
Java Wait for all Threads to Finish
Before executing threads:
ExecutorService es = Executors.newCachedThreadPool();
//execute all
es.shutdown();
//blocks until all are done
while (!es.awaitTermination(1, TimeUnit.MINUTES));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment