package com.itheima.MythoeadPool; import java.util.concurrent.*; public class MyThreadPooDemo3 { //1.核心线程数量 //2.最大线程数 //3.空闲线程最大存活时间 //4.时间单位 //5.认为队列 //6.创建线程工厂 //7.任务的拒绝策略 public static void main(String[] args) { ThreadPoolExecutor pool=new ThreadPoolExecutor(2,5,2, TimeUnit.SECONDS,new ArrayBlockingQueue<>(10),Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy()); pool.submit(new MyRunnable()); pool.submit(new MyRunnable()); pool.shutdown(); } } package com.itheima.MythoeadPool; public class MyRunnable implements Runnable{ @Override public void run() { System.out.println(Thread.currentThread().getName()+"在执行了"); } }