性能优化--实现子线程运行程序
2021/10/30 14:12:28
本文主要是介绍性能优化--实现子线程运行程序,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
性能优化–实现子线程运行程序:
微信发送消息数据优化
问题描述:
需求:用户体验慢,需要实现先返回后执行代码功能
通过子线程实现发送微信通知程序
线程创建和运行
ThreadUtil threadUtil = new ThreadUtil(systemService,userid,openid); threadUtil.start();
这里是线程创建得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(); } } }
解决方案:
另启一个线程发送即可
这篇关于性能优化--实现子线程运行程序的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28微服务架构中API版本控制的实践
- 2024-09-28AI给的和自己写的Python代码,都无法改变输入框的内容,替换也不行
- 2024-09-27Sentinel配置限流资料:新手入门教程
- 2024-09-27Sentinel配置限流资料详解
- 2024-09-27Sentinel限流资料:新手入门教程
- 2024-09-26Sentinel限流资料入门详解
- 2024-09-26Springboot框架资料:初学者入门教程
- 2024-09-26Springboot框架资料详解:新手入门教程
- 2024-09-26Springboot企业级开发资料:新手入门指南
- 2024-09-26SpringBoot企业级开发资料新手指南