refactor: 定时任务使用一个线程同步执行

This commit is contained in:
CaptainB 2024-04-03 13:02:35 +08:00 committed by 刘瑞斌
parent 7c0cab89af
commit 841a85a4c9
2 changed files with 49 additions and 60 deletions

View File

@ -57,14 +57,7 @@ public class CleanHistoryJob {
int size = 100;
List<List<String>> batchList = splitList(sourceIds, size);
batchList.forEach(batch -> {
Thread.startVirtualThread(new Runnable() {
@Override
public void run() {
cleanupHistory(batch, limit);
}
});
});
batchList.forEach(batch -> cleanupHistory(batch, limit));
}
private List<List<String>> splitList(List<String> list, int size) {

View File

@ -49,10 +49,7 @@ public class CleanUpReportJob {
for (int i = 0; i < pages; i++) {
int start = i * 100;
Thread.startVirtualThread(new Runnable() {
@Override
public void run() {
List<Project> projects = baseProjectMapper.selectProjectByLimit(start,100);
List<Project> projects = baseProjectMapper.selectProjectByLimit(start, 100);
projects.forEach(project -> {
ProjectApplicationExample applicationExample = new ProjectApplicationExample();
//test_plan
@ -101,8 +98,7 @@ public class CleanUpReportJob {
});
});
}
});
}
}