线程池实现
public class AsyncService { private ScheduledThreadPoolExecutor shceduleThreadPool = new ScheduledThreadPoolExecutor(5); private ThreadPoolExecutor threadPool = new ThreadPoolExecutor(10, 20, 600L, TimeUnit.SECONDS, new LinkedBlockingQueue()); public void execute(final Runnable runnable){ Runnable run = new Runnable(){ @Override public void run() { try{ runnable.run(); } catch(Exception e){ throw new RuntimeException(e); } } }; threadPool.execute(run); }
【线程池实现】}
使用
asyncService.execute(new Runnable() { @Override public void run() { TmsOrderInfoBO tmsOrderInfoBO = orderToTmsOrderInfoBO(order, createTime); tmsOrderInfoService.addTmsOrderInfo(tmsOrderInfoBO); tmsOrderInfoService.updateOrderResult(NumberCodeUtil.decode(order.getOrderId()), ResultCode.RESULT_NULL, null, new Date()); } });
推荐阅读
- 关于QueryWrapper|关于QueryWrapper,实现MybatisPlus多表关联查询方式
- MybatisPlus使用queryWrapper如何实现复杂查询
- python学习之|python学习之 实现QQ自动发送消息
- 孩子不是实现父母欲望的工具——林哈夫
- opencv|opencv C++模板匹配的简单实现
- Node.js中readline模块实现终端输入
- java中如何实现重建二叉树
- Linux下面如何查看tomcat已经使用多少线程
- 人脸识别|【人脸识别系列】| 实现自动化妆
- paddle|动手从头实现LSTM