如题,阻塞队列满了,但是线程池的线程数量小于maxPoolExecutor,此时增加新的任务,会立即执行新的任务,而不会从队列中取任务
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class ThreadSequence {
public static void main(String[] args) {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
3,
6,
10,
TimeUnit.MINUTES,
new ArrayBlockingQueue<>(3));
for (int i=0;i<10;i++){
int finalI = i;
threadPoolExecutor.execute(()->{
System.out.println(Thread.currentThread().getName() + "is executing" + finalI);
try {
Thread.sleep(10000000);
} catch (InterruptedException e) {
e.printStackTrace();
}
});
}
}