测试子线程

This commit is contained in:
wulin 2020-11-18 18:27:36 +08:00
parent 33d7a29f34
commit a3ef1860d4

View File

@ -106,8 +106,6 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
List<ThreadInitFlowRecord> threadInitFlowRecords = new ArrayList<>();
ThreadInitFlowRecord threadInitFlowRecord;
Thread thread;
@ -812,9 +810,9 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
private void initFlowRecordAnsy(List<ResultRecord> resultRecords, List<StaffSimpleInfo> noticeStaff){
if(resultRecords.size() > 0){
threadInitFlowRecord = new ThreadInitFlowRecord(resultRecords, noticeStaff);
threadInitFlowRecords.add(threadInitFlowRecord);//防止提前回收
thread = new Thread(threadInitFlowRecord);
ThreadInitFlowRecord threadInitFlowRecord = new ThreadInitFlowRecord(resultRecords, noticeStaff);
threadInitFlowRecords.add(threadInitFlowRecord);
Thread thread = new Thread(threadInitFlowRecord);
thread.start();
}
@ -822,12 +820,12 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
}
public class ThreadInitFlowRecord implements Runnable{
List<ResultRecord> resultRecords;
List<StaffSimpleInfo> noticeStaff;
List<ResultRecord> resultRecords = new ArrayList<>();
List<StaffSimpleInfo> noticeStaff = new ArrayList<>();
public ThreadInitFlowRecord(List<ResultRecord> resultRecords, List<StaffSimpleInfo> noticeStaff){
this.resultRecords = resultRecords;
this.noticeStaff = noticeStaff;
this.resultRecords.addAll(resultRecords);
this.noticeStaff.addAll(noticeStaff);
}
@Override
@ -836,20 +834,12 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
//String newNo = oldNo + "_initFlowRecord" ;//+ resultRecord.getStaffId() + "_" + resultRecord.getId();
//ch.qos.logback.classic.Logger.threadLocalNo.set(newNo);
log.info("开始批量初始化流程,数量{}", resultRecords.size());
for (int i = 0; i < 105; i++){
log.info("批量{}", i);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/*for (ResultRecord resultRecord:resultRecords
for (ResultRecord resultRecord:resultRecords
) {
resultRecordService.initFlowRecord(resultRecord.getId());
}*/
}
//ch.qos.logback.classic.Logger.threadLocalNo.set(oldNo);
dingtalkBusiness.sendWorkMSGWithAsyn(noticeStaff, WorkMsgTypeEnum.START_WORK.getType());
threadInitFlowRecords.remove(this);