@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
相关推荐
lxysbly18 小时前
ps1模拟器安卓版带金手指啊吧怪不啊吧21 小时前
UU远程协助迎来升级!第一期更新实测C_心欲无痕1 天前
ts - tsconfig.json配置讲解冰西瓜6001 天前
国科大2025操作系统高级教程期末回忆版HIT_Weston1 天前
93、【Ubuntu】【Hugo】搭建私人博客:面包屑(一)cuijiecheng20181 天前
Linux下Beyond Compare过期喵叔哟1 天前
20.部署与运维张世争1 天前
windows clion MingW cmake 编译运行 FreeRTOSHIT_Weston1 天前
92、【Ubuntu】【Hugo】搭建私人博客:侧边导航栏(六)CodeAllen嵌入式1 天前
Windows 11 本地安装 WSL 支持 Ubuntu 24.04 完整指南