当前位置:网站首页>线程执行测试效果
线程执行测试效果
2022-08-10 03:19:00 【道阻且长-行则将至-行而不辍-未来可期】
目录
前言描述:
主要是执行线程进行同步,简单的一个线程,后来废弃掉了,所以代码备份到这里
主要得线程代码
@Data
private class SendCorpusRunnable implements Runnable {
private Long newsId;
private List<TbmPopularFeelings> eventInfoList;
private Map<Long, List<TbmEventTags>> eventTagsMap;
public SendCorpusRunnable(Long newsId, List<TbmPopularFeelings> eventInfoList,
Map<Long, List<TbmEventTags>> eventTagsMap) {
this.newsId = newsId;
this.eventInfoList = eventInfoList;
this.eventTagsMap = eventTagsMap;
}
@Override
public void run() {
try {
NewsEventVo newsEventVo = TbmEventConvert.convertToCorpus(newsId, eventInfoList, eventTagsMap);
newsEventFacade.save(newsEventVo);
} catch (CorpusException e) {
e.printStackTrace();
}
}
}测试的地方里面的方法体进行的逻辑处理
/**
* 转换推送语料数据
*
* @param eventInfoList
* @return
*/
public static NewsEventVo convertToCorpus(Long newsId, List<TbmPopularFeelings> eventInfoList, Map<Long, List<TbmEventTags>> eventTagsMap) {
NewsEventVo newsEventVo = new NewsEventVo();
newsEventVo.setNewsId(newsId);
if (CollectionUtils.isEmpty(eventInfoList)) {
return newsEventVo;
}
List<NewsEventVo.EventCalloutVo> eventCalloutVoList = new ArrayList<>();
eventInfoList.forEach(eventInfo -> {
NewsEventVo.EventCalloutVo eventCalloutVo = new NewsEventVo.EventCalloutVo();
if (StringUtils.isNotBlank(eventInfo.getEventFourthLevelCode())) {
eventCalloutVo.setEventCode(eventInfo.getEventFourthLevelCode());
}
if (StringUtils.isNotBlank(eventInfo.getEventFourthLevel())) {
eventCalloutVo.setEventName(eventInfo.getEventFourthLevel());
}
if (StringUtils.isNotBlank(eventInfo.getEventBasis())) {
eventCalloutVo.setEventBasis(eventInfo.getEventBasis());
}
//提取标签主体
List<TbmEventTags> eventTagList = eventTagsMap.get(eventInfo.getId());
List<NewsEventVo.EventSubjectVo> subjectList = new ArrayList<>();
if (!CollectionUtils.isEmpty(eventTagList)) {
eventTagList.forEach(eventTag -> {
NewsEventVo.EventSubjectVo eventSubjectVo = new NewsEventVo.EventSubjectVo();
eventSubjectVo.setSubjectName(eventTag.getTagName());
if (StringUtils.isNotBlank(eventTag.getMainBasis())) {
eventSubjectVo.setSubjectBasis(eventTag.getMainBasis());
}
subjectList.add(eventSubjectVo);
});
}
eventCalloutVo.setSubjectList(subjectList);
eventCalloutVoList.add(eventCalloutVo);
});
newsEventVo.setEventList(eventCalloutVoList);
return newsEventVo;
}调用的时候:
// 发送语料平台,异步
ThreadPoolExecutor threadPoolExecutor = ThreadPoolExecutorFactory.getThreadPoolExecutor();
threadPoolExecutor.submit(new SendCorpusRunnable(newsId, tbmPopularFeelingsList, eventTagsMap)); // 发送语料平台,异步
ThreadPoolExecutor threadPoolExecutor = ThreadPoolExecutorFactory.getThreadPoolExecutor();
threadPoolExecutor.submit(new SendCorpusRunnable(newsId, tbmPopularFeelingsList, eventTagsMap));边栏推荐
猜你喜欢
随机推荐
如何整合全流程数据,全面提升研发效能?|2分钟了解 ONES
@Autowired注解 --required a single bean, but 2 were found出现的原因以及解决方法
请教各位confluence部署连接数据库成功,但是在后面建表设置的时候报错
uva1392
Software life cycle (the work of each phase of software engineering)
小程序分包及分包预下载
goland json.Marshal导致&变成\u0026
从零开始配置 vim(10)——快捷键配置
【IO复用】poll
js阻止事件冒泡方案
The same is a primary test, why does he pay 5,000 yuan more than me?
WPF 实现更换主题色
BFF避坑指南
How to quickly become a software test engineer?What skills do testers need for a monthly salary of 15k?
Example 043: Scope, class methods and variables
yolov5+usb相机
Embedded Sharing Collection 32
湖仓一体电商项目(四):项目数据种类与采集
常用类以及接口
如何开启热部署Devtools








