当前位置:网站首页>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:26: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
边栏推荐
- Zhangxiaobai teaches you how to use Ogg to synchronize Oracle 19C data with MySQL 5.7 (3)
- STM32 printf garbled
- Jerry's ble OTA upgrade requires shutting down unnecessary peripherals [chapter]
- Code implementation of partition case of MapReduce
- Necessary tools for automatic operation and maintenance shell script introduction
- Rk3308--8 channels changed to dual channels + recording gain
- 22. Generate Parentheses
- PV operation daily question - exam questions
- torch. nn. utils. rnn. pad_ Detailed explanation of sequence() [pytoch getting started manual]
- 姿态估计之2D人体姿态估计 - Human Pose Regression with Residual Log-likelihood Estimation(RLE)[仅链接]
猜你喜欢

【历史上的今天】6 月 10 日:Apple II 问世;微软收购 GECAD;发明“软件工程”一词的科技先驱出生

姿态估计之2D人体姿态估计 - Associative Embedding: End-to-End Learning for Joint Detection and Grouping
![Jerry's interface for obtaining ble broadcast package and profile data [chapter]](/img/ae/70cde8684fa536c37387ce819a36eb.png)
Jerry's interface for obtaining ble broadcast package and profile data [chapter]

Rk3308 key and LED light

Nerf: the popularity of using deep learning to complete 3D rendering tasks

Join operation cases in the map phase of MapReduce
![Jerry's long press reset and high level reset [chapter]](/img/08/900aba6e419cda2f00c3f289ad615e.png)
Jerry's long press reset and high level reset [chapter]

Sorting and paging

姿态估计之2D人体姿态估计 - Distribution Aware Coordinate Representation for Human Pose Estimation【转-修改】

RK3308--8声道改成双声道+录音增益
随机推荐
torch.nn.utils.rnn.pad_sequence()详解【Pytorch入门手册】
Error org codehaus. plexus. component. repository. exception. ComponentLookupException:
【無標題】
Detailed explanation of RGB color space, hue, saturation, brightness and HSV color space
2D human posture estimation for posture estimation - simple baseline (SBL)
姿态估计之2D人体姿态估计 - (OpenPose) Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields
Jerry's long press reset and high level reset [chapter]
LocalDate与Date相互转换
Add Anaconda's bin directory to path
Online document collaboration tool is the first step to improve work efficiency
Kubernetes binary installation (v1.20.16) (V) verifying master deployment
MapReduce之Reduce阶段的join操作案例
The CPU load caused by implicit conversion is nearly 100%
Rk3308--8 channels changed to dual channels + recording gain
软件测试架构师,给后辈的16条忠告,快看看别错过
Jerry's ble abnormal power consumption [chapter]
PHP wechat H5 payment demo
STM32 printf garbled
PV operation daily question - orange apple question (advanced version variant)
2D pose estimation for pose estimation - (openpose) realtime multi person 2D pose estimation using part affinity fields