测试线程池
package gaoji;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Testpool {
public static void main(String[] args) {
ExecutorService service = Executors.newFixedThreadPool(10);
service.execute(new MyTread());
service.execute(new MyTread());
service.execute(new MyTread());
service.execute(new MyTread());
service.shutdown();
}
}
class MyTread implements Runnable{
@Override
public void run() {
System.out.println(Thread.currentThread().getName() );
}
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210328210223390.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80OTQxOTY5NQ==,size_16,color_FFFFFF,t_70)