Created
August 1, 2013 04:00
-
-
Save tigawa/6128318 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.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
public class ThreadTest4 { | |
public static void main(String[] args) { | |
System.out.println("Entering main"); | |
ExecutorService exec = Executors.newFixedThreadPool(4); | |
for (int i = 0; i < 10; i++) { | |
exec.execute(new Runnable() { | |
public void run() { | |
try { | |
System.out.println("Hello! - " + Thread.currentThread().getId()); | |
Thread.sleep(1 * 3000); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
} | |
System.out.println("Exit main"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment