@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
相关推荐
深紫色的三北六号2 小时前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)SudosuBash6 小时前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)哈基咪怎么可能是AI16 小时前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️十日十行1 天前
Linux和window共享文件夹木心月转码ing2 天前
WSL+Cpp开发环境配置蝎子莱莱爱打怪3 天前
Centos7中一键安装K8s集群以及Rancher安装记录埃博拉酱3 天前
VS Code Remote SSH 连接 Windows 服务器卡在"下载 VS Code 服务器":prcdn DNS 解析失败的诊断与 BITS 断点续传崔小汤呀3 天前
最全的docker安装笔记,包含CentOS和Ubuntu何中应3 天前
vi编辑器使用何中应3 天前
Linux进程无法被kill