当前位置:网站首页>Why do I need a thread pool? What is pooling technology?
Why do I need a thread pool? What is pooling technology?
2022-06-10 16:28:00 【InfoQ】
1. Pool technology
- according to new Parameter after identifier , Find the symbolic reference of the class in the constant pool ;
- If no symbol application is found ( Class is not loaded ), Load the class 、 analysis 、 Initialization etc. ;
- The virtual machine allocates memory for objects in the heap , And initialize the allocated memory to 0, For object headers , Establish the corresponding description structure ( The long-running : You need to find the free area in the heap , Modify memory allocation status, etc );
- Invokes the initialization method of the object ( The long-running : User's complex logic verification and other operations , Such as IO、 Whether the numerical calculation meets the regulations, etc ).
2. Application of pooling Technology
2.1 Thread pool

2.2 Memory pool
- Reduce memory fragmentation , This advantage can be seen in the process of creating memory pools , When we are creating a memory pool , All the allocated memory blocks are relatively regular memory blocks , Reduce memory fragmentation .
- Increased memory usage . This can be seen from the process of allocating and freeing memory . Each allocation and release is not to call the functions or operators provided by the system to operate the actual memory , Instead, reuse the memory in the memory pool .
2.3 Database connection pool

2.4 HttpClient Connection pool
3. Introduction to thread pool
4. Analysis of the advantages of thread pool

advantage 1: Reuse threads , Reduce resource consumption

advantage 2: Improve response time
advantage 3: Control the number of threads and tasks
- Control the maximum concurrent number : The thread pool can create a fixed number of threads , This avoids the problem of unlimited thread creation . When too many threads are created , Will cause the system to execute slowly , because CPU The number of cores is certain 、 The number of tasks that can be processed at the same time is also certain , When there are too many threads, it will cause malicious contention and frequent thread switching , This causes the program to execute slowly , Therefore, the appropriate number of threads is the key to high-performance operation .
- Control the maximum number of tasks : If there are unlimited tasks , When there is not enough memory , It will cause the program execution to report an error , The thread pool can control the maximum number of tasks , When the task exceeds a certain number , Will use the rejection strategy to deal with the extra tasks , So as to ensure the healthy operation of the system .
advantage 4: More enhancements
summary
Last
边栏推荐
- Diagram of the quarterly report of station B: the revenue is RMB 5.1 billion, with a year-on-year increase of 30% and nearly 300million monthly active users
- What are the top ten futures companies with low handling fees? Is it safe?
- Sorting of MapReduce cases
- Error org codehaus. plexus. component. repository. exception. ComponentLookupException:
- I used Matlab to reproduce the trembling sonic boom Fire Games Apple snake
- Scope and closure
- 服务器运维环境安全体系(下篇)
- Join operation cases in the map phase of MapReduce
- MapReduce之排序及序列化案例的代码实现
- Financial risk control practice - anomaly detection (I)
猜你喜欢
![Google X开源抓取机械臂,无需人工标注就能一眼找到目标零件[转]](/img/69/02a3e0eeaf3049f41b118cf0c58972.jpg)
Google X开源抓取机械臂,无需人工标注就能一眼找到目标零件[转]

Live broadcast preview | deconstruct OLAP! The new multidimensional analysis architecture paradigm is fully open! Apache Doris will bring five big issues!
![姿态估计之2D人体姿态估计 - Human Pose Regression with Residual Log-likelihood Estimation(RLE)[仅链接]](/img/c7/9c25da07236ef0bd241b6023e82306.gif)
姿态估计之2D人体姿态估计 - Human Pose Regression with Residual Log-likelihood Estimation(RLE)[仅链接]

Actual combat of software testing e-commerce project (actual combat video station B has been released)

2D human posture estimation for posture estimation - associated embedding: end to end learning for joint detection and grouping

RK3308--8声道改成双声道+录音增益

Unified certification center oauth2 certification pit
![[MySQL basics]](/img/fc/48e9c6b739e29472a7a103e47663af.png)
[MySQL basics]

Distribution aware coordinate representation for human pose estimation

MapReduce之排序及序列化案例的代码实现
随机推荐
C # homework - student information management system
MapReduce案例之排序
LocalDate与Date相互转换
Come with me to understand gaussdb (for opengauss) [Gauss is not a mathematician this time]
Fortex Fangda releases the electronic trading ecosystem to share and win-win with customers
Matlab learning notes (3) advanced operation of MATLAB matrix
Diagram of the quarterly report of station B: the revenue is RMB 5.1 billion, with a year-on-year increase of 30% and nearly 300million monthly active users
PV operation daily question 1 - single wooden bridge problem (variant 2)
New York financial regulators issue official guidelines for stable currency
软件测试架构师,给后辈的16条忠告,快看看别错过
Anba cv2fs/cv22fs obtained ASIL C chip function safety certification, surpassing the level of similar chips in the market
Sword finger offer 06 Print linked list from end to end
MapReduce之Map阶段的join操作案例
运行mapreduce任务缺失setJarByClass()报错找不到类
Digital image processing: graying
Online document collaboration tool is the first step to improve work efficiency
Software test architects, 16 pieces of advice for future generations, take a look and don't miss it
leetcode:730. 统计不同回文子序列【由点及面区间dp + 三维dp + 对角线遍历】
Jerry's ble PB2 cannot be hardware grounded or connected to triode base [chapter]
Driver development and abnormal analysis of "technical dry goods" industrial touch screen (serial)