阻塞对列的4种用法 LinkedBlockingDeque /ArrayBlockingQueue
类型 阻塞 直接返回 抛异常 等待超时退出
添加 put offer add offer
删除 take poll remove poll
线程池:
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,
5,
2,
TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(3),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.AbortPolicy()
);
threadPoolExecutor.execute(()->{
System.out.println("test");
});