子线程测试

This commit is contained in:
wulin 2020-11-18 15:05:34 +08:00
parent 5b9376d3b7
commit 3d962752bd
2 changed files with 9 additions and 3 deletions

View File

@ -103,7 +103,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
@Autowired
private DingtalkBusiness dingtalkBusiness;
List<ThreadInitFlowRecord> threads = new ArrayList<>();
List<ThreadInitFlowRecord> threadInitFlowRecords = new ArrayList<>();
@ -811,9 +811,10 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
private void initFlowRecordAnsy(List<ResultRecord> resultRecords, List<StaffSimpleInfo> noticeStaff){
if(resultRecords.size() > 0){
ThreadInitFlowRecord threadInitFlowRecord = new ThreadInitFlowRecord(resultRecords, noticeStaff);
threadInitFlowRecords.add(threadInitFlowRecord);//防止提前回收
Thread thread = new Thread(threadInitFlowRecord);
thread.start();
threads.add(threadInitFlowRecord);
}
}
@ -841,7 +842,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
}
//ch.qos.logback.classic.Logger.threadLocalNo.set(oldNo);
dingtalkBusiness.sendWorkMSGWithAsyn(noticeStaff, WorkMsgTypeEnum.START_WORK.getType());
threads.remove(this);
threadInitFlowRecords.remove(this);
}
}
}

View File

@ -77,6 +77,8 @@ public class DingtalkBusiness {
@Resource
StaffDao staffDao;
List<ThreadSendMessage> threadSendMessages = new ArrayList<>();
@Value("${dingtalk.appid}")
private String appid;
@ -257,8 +259,10 @@ public class DingtalkBusiness {
WorkMsgTypeEnum workMsgTypeEnum = WorkMsgTypeEnum.findRoleTypeByCode(type);
ThreadSendMessage threadSendMessage = new ThreadSendMessage(fromStaff, toStaffids, workMsgTypeEnum, appid);
threadSendMessages.add(threadSendMessage);//防止提前回收
Thread thread = new Thread(threadSendMessage);
thread.start();
return "OK";
}
return "error";
@ -391,6 +395,7 @@ public class DingtalkBusiness {
logger.info("ThreadSendMessage token无效"); ;
}
}
threadSendMessages.remove(this);
}
}
}