当前位置:网站首页>Thread pool: use thread pool to optimize query speed
Thread pool: use thread pool to optimize query speed
2022-07-04 05:11:00 【Gu Gugu】
For two unrelated businesses on the same page , We can optimize through thread pool .
Two test classes are written here , Compare
The speed gap between sequential execution and query using thread pool
@Test
public void test211(){
Long beginTime = new Date().getTime();
System.out.println(beginTime+"-------- current time ");
List<ActivityInfo> activity=activityService.listall("");
List<ActivityInfo> activity2=activityService.listall("");
Long endTime = new Date().getTime();
System.out.println(endTime+"-------- End time ");
System.out.println(new Date().getTime()-beginTime+"-------- Spend time ");
}
@Test
public void test212() throws InterruptedException {
Long beginTime = new Date().getTime();
System.out.println(beginTime+"-------- current time ");
ExecutorService executorService = Executors.newFixedThreadPool(2);
executorService.submit(()->{
List<ActivityInfo> activity=activityService.listall("");
});
executorService.submit(()->{
List<ActivityInfo> activity2=activityService.listall("");
});
executorService.shutdown();
executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MINUTES);
Long endTime = new Date().getTime();
System.out.println(endTime+"-------- End time ");
System.out.println(new Date().getTime()-beginTime+"-------- Spend time ");
}
Here is a small query written by yourself , So the difference is not big , When the data volume comes up, there will be an obvious speed gap .
边栏推荐
- Annex II: confidentiality agreement for offensive and defensive drills docx
- Flutter ‘/usr/lib/libswiftCore.dylib‘ (no such file)
- Zkevm (12) state proof of appliedzkp
- cmake
- 【MATLAB】MATLAB 仿真数字基带传输系统 — 双极性基带信号(第 I 类部分响应波形)的眼图
- 由于使用flash存放参数时,擦除掉了flash的代码区导致进入硬件错误中断
- TCP state transition diagram
- Graduation design of small programs -- small programs of food and recipes
- Annex 2-2 confidentiality commitment docx
- Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3
猜你喜欢

Useful plug-ins for vscode

Use units of measure in your code for a better life

2022G2电站锅炉司炉特种作业证考试题库及答案

Zhongke panyun-d module analysis and scoring standard

Secondary vocational group network security - memory Forensics

Automated testing selenium foundation -- webdriverapi
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

Character types of C language

Sécurité du réseau dans les écoles professionnelles secondaires - preuve de mémoire

海力士EMMC5.0及5.1系列对比详解
随机推荐
由于使用flash存放参数时,擦除掉了flash的代码区导致进入硬件错误中断
2022 question bank and answers for safety management personnel of hazardous chemical business units
2022年T电梯修理操作证考试题库及模拟考试
Share some of my telecommuting experience
Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
ping端口神器psping
2022年R2移动式压力容器充装复训题库及答案
LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
海力士EMMC5.0及5.1系列对比详解
PostgreSQL has officially surpassed mysql. Is this guy too strong!
Simple g++ and GDB debugging
小程序毕业设计---美食、菜谱小程序
【QT】定时器
加密和解密
【MATLAB】通信信号调制通用函数 — 窄带高斯白噪声的生成
自动化测试selenium基础篇——webdriverAPI
关于solidworks standard无法获得许可 8544问题的总结
[paper summary] zero shot semantic segmentation
中科磐云—D模块解析以及评分标准
Notepad++--显示相关的配置