Created
May 24, 2019 00:50
-
-
Save cnmoro/be4aaccb6da479e22867c5eab5c2eae3 to your computer and use it in GitHub Desktop.
Java Wait for all Threads to Finish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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