1、创建大小固定的线程池
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Test {
//创建一个固定大小为15的 线程池
private static ExecutorService executor = Executors.newFixedThreadPool(15);
public static void main(String[] args) {
System.out.println("1");
for(int i = 0; i < 50; i++){
executor.execute(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
while(true){
System.out.println(Thread.currentThread().getName()+"**");
}
}
});
}
}
}