Last active
November 7, 2015 13:04
-
-
Save AtomicBlom/9e0a785e6715403c6462 to your computer and use it in GitHub Desktop.
This file contains 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
//Keep track of the threads doing work | |
Thread[] threads = new Thread[10]; | |
//Create 10 threads | |
for (int i = 0; i < 10; i++) { | |
//You need to create a Runnable class instance (anonymous class works too) | |
threads[i] = new Thread(new BluSunrizeSuperItemCheckerThing()); | |
//Start the thread processing immediately | |
threads[i].start(); | |
} | |
//iterate over each thread individually | |
for (final Thread thread : threads) | |
{ | |
try { | |
//Wait for this thread to finish. If it's already finished, this will proceed immediately. | |
thread.join(); | |
} catch (InterruptedException e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
//This line will only execute once all 10 threads have finished | |
System.out.print("done!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment