当前位置:网站首页>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 .
边栏推荐
- STM32F1与STM32CubeIDE编程实例-74HC595驱动4位7段数码管
- A summary of the 8544 problem that SolidWorks Standard cannot obtain a license
- Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
- [matlab] general function of communication signal modulation bandpass filter
- [matlab] matlab simulation - low pass Gaussian white noise
- [paper summary] zero shot semantic segmentation
- Electronic components mall and data manual download website summary
- 【MATLAB】MATLAB 仿真 — 窄带高斯白噪声
- [技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
- Yolov6 practice: teach you to use yolov6 for object detection (with data set)
猜你喜欢

企业级日志分析系统ELK(如果事与愿违那一定另有安排)

中科磐云—2022广东木马信息获取解析

Automated testing selenium foundation -- webdriverapi

A summary of the 8544 problem that SolidWorks Standard cannot obtain a license

STM32F1与STM32CubeIDE编程实例-74HC595驱动4位7段数码管

Flutter 调用高德地图APP实现位置搜索、路线规划、逆地理编码

Useful plug-ins for vscode

Character types of C language
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

Customize a pager needed in your project
随机推荐
令人头痛的延时双删
Flutter ‘/usr/lib/libswiftCore.dylib‘ (no such file)
LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
Remote desktop client RDP
[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
[matlab] communication signal modulation general function - low pass filter
Headache delayed double deletion
2022年R2移动式压力容器充装复训题库及答案
Annex 4: scoring criteria of the attacker docx
由于使用flash存放参数时,擦除掉了flash的代码区导致进入硬件错误中断
Unity is connected to the weather system
Notes on the paper "cross view transformers for real time map view semantic segmentation"
模拟小根堆
[matlab] matlab simulation modulation system FM system
【MATLAB】通信信号调制通用函数 — 带通滤波器
在代碼中使用度量單比特,從而生活更美好
我们认为消费互联网发展到最后,依然会局限于互联网行业本身
PostgreSQL has officially surpassed mysql. Is this guy too strong!
Annex 2-2 confidentiality commitment docx
【MATLAB】MATLAB 仿真模拟调制系统 — FM 系统