@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
相关推荐
Lonely 净土6 小时前
Linux 运维文件写入操作飞英思特无线充电7 小时前
严苛场景巡检机器人的无线补能设计:点位、BMS、认证与运维边界Jimmy_jimi7 小时前
利用nginx代理完成url重定位liuyicenysabel7 小时前
多服务上线日记三:吠品9 小时前
Wine 在 Linux 上运行 Windows 软件完整指南一只鹿鹿鹿9 小时前
大数据中心安全系统解决方案(Word文件)深念Y11 小时前
从 Windows 迁移到 Linux 开发环境的记录领创工作室11 小时前
GitHub Workflows 全面解析:从核心概念到开源实现吕海洋12 小时前
目前可用的docker源2026.08知无不研12 小时前
Linux I/O复用之epoll