- 声明
private final static ArrayBlockingQueue<Runnable> WORK_QUEUE= new ArrayBlockingQueue<>(9);// handler – 由于达到线程边界和队列容量而阻塞执行时使用的处理程序private final static RejectedExecutionHandler HANDLER=new ThreadPoolExecutor.CallerRunsPolicy();private static ThreadPoolExecutor executorService = new ThreadPoolExecutor(16, 16, 1000, TimeUnit.MILLISECONDS, WORK_QUEUE, HANDLER);
- 使用,通过 get() 方法获取他的返回值
//商品属性Callable<List> listCallable=()->goodsAttributeService.getGoodsAttributeList(litemallGoods.getGoodsSn());//商品规格Callable<Object> specificationCallable =()->specificationService.getGoodsSpecification(litemallGoods.getGoodsSn());FutureTask<List> goodsAttributeListTask = new FutureTask<>(listCallable);FutureTask<Object> objectCallableTask = new FutureTask<>(specificationCallable);executorService.submit(goodsAttributeListTask);executorService.submit(objectCallableTask);
经验总结扩展阅读
- 2023淘宝抢茅台下单太多活动火爆是账号黑了吗 淘宝抢茅台下单太多活动火爆怎么办
- 驱动开发:内核中实现Dump进程转储
- 家装碳晶板可以用多久呢
- 冰块可以保存多久
- 本地法拍房在哪里看
- 第二套房公积金贷款利率是多少
- 杭瑞高速全程多少公里
- 120斤适合多重的呼啦圈
- 小米11尺寸多大_小米11的外观尺寸
- 肉要煮多久才能熟