In-depth analysis of pooling technology
In the Java language, there are two ways to improve the execution efficiency of the program, one is to use threads and the other is to use thread pools.
In production environments, we usually use the latter.
Why is this so? Today we will talk about the advantages of thread pools, as well as pooling technology and its applications.
Pooling Technology.
Pooling technology refers to preparing some resources in advance, and these pre-prepared resources can be reused when needed.
There are two main advantages of pooling technology: preparation in advance and reuse.
Taking object creation in the Java language as an example, the following steps are required to create an object:
- According to the parameters after the
new
identifier, look up the symbolic reference of the class in the constant pool. - If the symbol application is not found (the class is not loaded), load, parse, initialize the class, etc.
- The virtual machine allocates memory in the heap for the object and initializes the allocated memory to
0
. For the object header, the corresponding description structure is created (time-consuming operations: need…