性能优化–实现子线程运行程序: 微信发送消息数据优化
问题描述: 需求:用户体验慢,需要实现先返回后执行代码功能
通过子线程实现发送微信通知程序 线程创建和运行
ThreadUtil threadUtil = new ThreadUtil(systemService,userid,openid); threadUtil.start(); 1 2 这里是线程创建得run方法实现
package com.jeecg.pai.extend.util;
import com.jeecg.offical.util.GlobalConfig; import org.jeecgframework.web.system.service.SystemService;
import java.io.IOException;
public class ThreadUtil extends Thread { private String userid; private SystemService systemService; private String openid; public ThreadUtil(SystemService systemService,String userid,String openid){ this.userid=userid; this.systemService=systemService; this.openid=openid;
}
public ThreadUtil() {
}
public ThreadUtil(String thread1) {
}
public void run() {
try {
System.out.println("openid =进入了子线程 " + openid);
GlobalConfig.noticeManagerAuditAd(systemService, userid, openid, 2);
} catch (IOException e) {
e.printStackTrace();
}
}
} 解决方案: 另启一个线程发送即可