Skip to content

Instantly share code, notes, and snippets.

@tigawa
Created August 1, 2013 04:00
Show Gist options
  • Save tigawa/6128318 to your computer and use it in GitHub Desktop.
Save tigawa/6128318 to your computer and use it in GitHub Desktop.
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