当前位置:网站首页>线程执行测试效果
线程执行测试效果
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));
边栏推荐
猜你喜欢
随机推荐
applet wxs
flutter异步
量化投资学习——在FPGA上运行高频交易策略
golang:base64编解码(转)
uva1392
cuda——nms
网路编程_调试accept
Kettle 裁剪表详解(truncate)
使用 requestAnimationFrame 提升 web 性能
如何让导电滑环信号更好
The same is a primary test, why does he pay 5,000 yuan more than me?
是什么让训练综合分类网络艰苦?
小程序wxs
matlab simulink响应谱计算
使用注解实现限流
《天才基本法》:平行时空的第二次选择,小演员的表现意外出圈
Camera partial update
笔试题记录
flink 12 源码编译及使用idea运行、debug
Small program subcontracting and subcontracting pre-download