@Component
@Slf4j
@Async
public class ThreadSaveDigCategory {
private static final int BATCH_COUTN = 1000;
@Autowired
private Mapper mapper;
public Future<Boolean> saveDigCategoryDatas(List<DigCategoryData> digCategoryDataList){
//开始计时
long startTime = System.currentTimeMillis();
// mapper.saveDigCategoryData(digCategoryDataList);
//数据分批处理
List<List<DigCategoryData>> batchList = BathProcessUtil.batchList(digCategoryDataList, BATCH_COUTN);
for (List<DigCategoryData> batch : batchList){
mapper.saveDigCategoryData(batch);
}
//endTime
long endTime = System.currentTimeMillis();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(endTime-startTime);
log.info("耗时: " + calendar.get(Calendar.MINUTE) + "分 " + calendar.get(Calendar.SECOND) + "秒 " +
calendar.get(Calendar.MILLISECOND) + " 微秒" + "-" + "数据保存成功");
return new AsyncResult<>(true);
}
}
多线程返回计时问题代码案例
928-y2023-11-09 13:43
相关推荐
MilesShi2 小时前
从 scheduler_tick 到上下文切换:深入解析 Linux 内核的 TIF_NEED_RESCHED 标志设置流程方渐鸿5 小时前
【2024】k8s集群 图文详细 部署安装使用(两万字)我爱云计算5 小时前
K8S详解(5万字详细教程)明明跟你说过5 小时前
【k8s】资源限制管理:Namespace、Deployment与Pod的实践2301_794333917 小时前
实验室服务器配置|通过Docker实现Linux系统多用户隔离与安全防控打码人的日常分享7 小时前
运维服务方案,运维巡检方案,运维安全保障方案文件荣光波比8 小时前
Nginx 实战系列(一)—— Web 核心概念、HTTP/HTTPS协议 与 Nginx 安装武文斌778 小时前
单片机:DS18B20测温度、74HC595扩展芯片、8*8LED矩阵fengfuyao9859 小时前
诊断并修复SSH连接Github时遇到的“connection closed“错误scugxl9 小时前
centos7 docker离线安装