Created
October 8, 2014 03:02
-
-
Save ericdcobb/2192d976c83188a9f98b to your computer and use it in GitHub Desktop.
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
| import java.util.*; | |
| import java.util.concurrent.*; | |
| public class Sample { | |
| public static void main(String[] args) throws Exception { | |
| ExecutorService executorService = Executors.newFixedThreadPool(10); | |
| for(int i = 0; i < 10; i++) { | |
| final int index = i; | |
| executorService.submit(new Runnable() { | |
| public void run() { | |
| System.out.println("Running task " + index); | |
| } | |
| }); | |
| } | |
| System.out.println("Tasks started..."); | |
| executorService.shutdown(); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment