package com.company;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
class th1 implements Runnable{
@Override
public void run() {
System.out.println(Thread.currentThread().getName()+"正在执行");
}
}
class th2 implements ThreadFactory{
public Thread newThread(Runnable r){
return new Thread(r);
}
}
public class Main{
public static void main(String[] args){
ExecutorService ex=Executors.newFixedThreadPool(3);
ex.submit(new th1());
ex.submit(new th1());
ex.submit(new th1());
ex.shutdown();
ExecutorService ex1=Executors.newFixedThreadPool(2,new th2());
for(int i=1;i<4;i++){
ex1.submit(new th1());
}
ex1.shutdown();
}
}