测试线程池三种创建方法
package cn.edut.com.tarena;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Test4 {
public static void main(String[] args) {
ExecutorService pool = null;
pool = Executors.newFixedThreadPool(10);
for (int i = 0; i < 1000; i++) {
pool.execute(new T1(i));
}
pool.shutdown();
}
static class T1 implements Runnable{
private int id ;
public T1(int n) {
id = n ;
}
@Override
public void run() {
System.out.println(Thread.currentThread().getName() +" : "+ id);
}
}
}