Thread pool management method and system, electronic equipment and storage medium

By dynamically managing thread pools, adjusting the thread pool size according to the size of pending data and server resource utilization, solving the problems of uneven resource allocation and waste in the existing technology, and achieving efficient concurrent processing and stability.

CN119248440APending Publication Date: 2025-01-03SUNSHINE LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411190267.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

The existing thread pool management technology has problems such as uneven resource allocation, waste and insufficient reuse in high concurrency scenarios, resulting in tight and collapse of system resources and lack of intelligent judgment and control.

Method used

By judging whether to perform multi-threaded concurrent processing based on the size of the pending data, dynamically adjusting the thread pool size according to the server resource utilization, creating and recycling thread pools, to achieve intelligent resource management.

Benefits of technology

Efficient concurrent processing is achieved, excessive resource consumption and waste are avoided, and system stability and resource utilization are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248440A_ABST
    Figure CN119248440A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of database agents, in particular to a thread pool management method and system, electronic equipment and a storage medium, and the method comprises the following steps: based on the size of to-be-processed data, judging whether to perform multi-thread concurrent processing on the to-be-processed data to obtain a first judgment result; when the first judgment result is yes, if the number of the current available thread pools does not meet the number of the thread pools required by the to-be-processed data, judging whether a new thread pool can be created or not according to the resource utilization rate of the server, and obtaining a second judgment result; and when the second judgment result is yes, performing multi-thread concurrent processing on the to-be-processed data by utilizing the created current available thread pool, and after the to-be-processed data is processed, performing recovery management on the created current available thread pool. Through dynamic management of the thread pool, the resource use condition of the system can be monitored in real time, the scale of the thread pool can be intelligently adjusted, the efficient concurrent processing effect is achieved, and meanwhile excessive consumption and waste of resources are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] With the widespread application of cloud computing and microservice architecture, modern software systems are facing unprecedented high-concurrency processing requirements. In high-concurrency scenarios, thread pools are widely used as an effective concurrent processing mechanism to process large numbers of requests and data. However, existing thread pool management technologies such as Spring's ThreadPoolTaskExecutor and JDK's Executors, although providing basic thread pool initialization and usage functions, still lack effective centralized management of thread pools in actual applications, resulting in uneven resource allocation and waste. And the lack of intelligent judgment and control of resource utilization leads to the blind creation of new thread pools when resources are tight, aggravating the shortage of system resources and even causing system crashes. At the same time, there are also deficiencies in the reuse and recycling of thread pools, resulting in the destruction of thread pools after the task is completed, which cannot be effectively used, thereby wasting system resources and increasing the delay and cost of subsequent task processing.

[0003] Therefore, it is urgent to provide a technical solution to solve the above problems. Summary of the invention

[0004] In order to solve the above technical problems, the present invention provides a thread pool management method, system, electronic device and storage medium.

[0005] In a first aspect, the present invention provides a thread pool management method, the technical solution of the method is as follows:

[0006] Based on the size of the data to be processed, determining whether to perform multi-thread concurrent processing on the data to be processed, and obtaining a first determination result;

[0007] When the first judgment result is yes, if the number of currently available thread pools does not meet the number of thread pools required by the data to be processed, then judging whether a new thread pool can be created according to the server resource utilization rate, and obtaining a second judgment result;

[0008] When the second judgment result is yes, the created currently available thread pool is used to perform multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, the created currently available thread pool is recycled.

[0009] The beneficial effects of a thread pool management method of the present invention are as follows:

[0010] The method of the present invention can monitor the usage of system resources in real time and intelligently adjust the size of the thread pool through dynamic management of the thread pool, thereby achieving efficient concurrent processing effects and avoiding excessive consumption and waste of resources.

[0011] Based on the above solution, a thread pool management method of the present invention can also be improved as follows.

[0012] In an optional manner, the thread pool management method further includes: when the first judgment result is no, using a single thread pool to process the data to be processed.

[0013] In the above optional manner, the efficiency of processing small-scale data is further improved, the resource overhead caused by creating multiple thread pools for small-scale data is avoided, and the rational use of resources is achieved.

[0014] In an optional manner, the thread pool management method also includes: if the number of currently available thread pools meets the number of thread pools required by the data to be processed, using the currently available thread pools with the number of thread pools required by the data to be processed, performing multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, recycling management of the currently available thread pools.

[0015] In the above optional manner, by directly utilizing existing thread pool resources, the number of times the thread pool is created and destroyed is reduced, the reuse rate of the thread pool is improved, and thus the consumption of system resources is reduced.

[0016] In an optional manner, the thread pool management method further includes: when the second judgment result is no, using the currently available thread pool to process the data to be processed, and after the processing of the data to be processed is completed, recycling management of the currently available thread pool.

[0017] In the above optional manner, when resources are tight, by giving priority to using existing thread pool resources to process tasks, further resource tension caused by creating a new thread pool is avoided, thereby ensuring stable operation of the system.

[0018] In an optional manner, the step of performing recycling management on any thread pool includes: determining whether any thread pool is a newly created thread pool, and obtaining a third determination result;

[0019] When the third judgment result is yes, close any one of the thread pools and release resources; when the third judgment result is no, set any one of the thread pools as an available thread pool for reuse.

[0020] In the above optional method, intelligent recycling management of the thread pool is further realized. For the newly created thread pool, the resources are closed and released in time after the task is completed, thereby avoiding long-term occupation of resources; and for the non-newly created thread pool, the number of creation and destruction of the thread pool is reduced through reuse, thereby improving the efficiency of resource utilization.

[0021] In a second aspect, the present invention provides a thread pool management system, the technical solution of which is as follows:

[0022] The thread pool management system comprises: a first judgment module, a second judgment module and a first execution module;

[0023] The first judgment module is used to: judge whether to perform multi-thread concurrent processing on the data to be processed based on the size of the data to be processed, and obtain a first judgment result;

[0024] The second judgment module is used to: when the first judgment result is yes, if the number of currently available thread pools does not meet the number of thread pools required by the data to be processed, determine whether a new thread pool can be created according to the server resource utilization rate to obtain a second judgment result;

[0025] The first execution module is used for: when the second judgment result is yes, using the created currently available thread pool to perform multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, recycling management of the created currently available thread pool.

[0026] The beneficial effects of a thread pool management system of the present invention are as follows:

[0027] The system of the present invention can monitor the usage of system resources in real time and intelligently adjust the size of the thread pool through dynamic management of the thread pool, thereby achieving efficient concurrent processing effects and avoiding excessive consumption and waste of resources.

[0028] Based on the above solution, a thread pool management system of the present invention can also be improved as follows.

[0029] In an optional manner, the thread pool management system further includes: a second execution module;

[0030] The second execution module is used for: when the first judgment result is no, using a single thread pool to process the data to be processed.

[0031] In the above optional manner, the efficiency of processing small-scale data is further improved, the resource overhead caused by creating multiple thread pools for small-scale data is avoided, and the rational use of resources is achieved.

[0032] In an optional manner, the thread pool management system further includes: a third execution module;

[0033] The third execution module is used to: if the number of currently available thread pools meets the number of thread pools required by the data to be processed, use the currently available thread pools with the number of thread pools required by the data to be processed to perform multi-threaded concurrent processing on the data to be processed, and recycle the currently available thread pools after the processing of the data to be processed is completed.

[0034] In the above optional manner, by directly utilizing existing thread pool resources, the number of times the thread pool is created and destroyed is reduced, the reuse rate of the thread pool is improved, and thus the consumption of system resources is reduced.

[0035] In a third aspect, a technical solution of an electronic device of the present invention is as follows:

[0036] The invention comprises a memory, a processor and a program stored in the memory and running on the processor. When the processor executes the program, the steps of the thread pool management method of the present invention are implemented.

[0037] In a fourth aspect, the present invention provides a computer-readable storage medium having the following technical solution:

[0038] Instructions are stored in the computer-readable storage medium. When the computer-readable storage medium reads the instructions, the computer-readable storage medium executes the steps of the thread pool management method of the present invention.

[0039] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:

[0041] Figure 1 A schematic diagram of a process flow of an embodiment of a thread pool management method of the present invention;

[0042] Figure 2 It is an overall flow chart of a thread pool management method of the present invention;

[0043] Figure 3 A technical architecture diagram of a thread pool management method of the present invention;

[0044] Figure 4 A schematic diagram of the structure of an embodiment of a thread pool management system of the present invention;

[0045] Figure 5The figure is a schematic structural diagram of an embodiment of an electronic device of the present invention. DETAILED DESCRIPTION

[0046] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.

[0047] Figure 1 FIG. 1 is a flow chart showing an embodiment of a thread pool management method provided by the present invention, wherein the method is executed by a controller. Figure 1 As shown, the following steps are included:

[0048] S1. Based on the size of the data to be processed, determine whether to perform multi-threaded concurrent processing on the data to be processed, and obtain a first determination result. In S1:

[0049] 1) Data to be processed refers to data that needs to be processed or analyzed in this embodiment.

[0050] 2) The first judgment result refers to the preliminary judgment result of whether to perform multi-threaded concurrent processing based on the size of the data to be processed. The first judgment result is used to guide the subsequent processing flow.

[0051] Specifically, the controller determines whether to perform multi-thread concurrent processing on the data to be processed based on the size of the data to be processed, and obtains a first determination result.

[0052] S2. When the first judgment result is yes, if the number of currently available thread pools does not meet the number of thread pools required for the data to be processed, then based on the server resource utilization rate, determine whether a new thread pool can be created to obtain a second judgment result. In S2:

[0053] 1) The currently available thread pool refers to the thread pool resources that already exist and are not fully occupied in the server corresponding to the controller of this embodiment. The currently available thread pool is used to execute concurrent tasks, reduce the overhead of thread creation and destruction, and improve system efficiency.

[0054] 2) The thread pool required for the data to be processed is an estimated amount of thread pool resources required to process the data to be processed based on the size of the data to be processed and the processing requirements.

[0055] 3) Server resource utilization refers to the ratio of the CPU, memory and other resources currently in use to the total resources in the server corresponding to the controller of this embodiment. The server resource utilization is used as a basis for determining whether a new thread pool can be created, thereby avoiding system performance degradation due to insufficient resources.

[0056] 4) A new thread pool refers to a thread pool resource that is newly created based on demand when the existing thread pool resources are insufficient. The new thread pool can provide additional concurrent processing capabilities for the data to be processed.

[0057] 5) The second judgment result is a judgment result of whether a new thread pool can be created based on the JVM utilization rate and the current server resource utilization rate. The second judgment result is used to guide whether to perform the creation operation of a new thread pool to ensure the effective use and stability of system resources.

[0058] Specifically, when the first judgment result is yes, if the number of currently available thread pools does not meet the number of thread pools required for the data to be processed, the controller determines whether a new thread pool can be created based on the JVM utilization rate and the server resource utilization rate to obtain a second judgment result.

[0059] S3. When the second judgment result is yes, the currently available thread pool created is used to perform multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, the currently available thread pool created is recycled and managed. In S3:

[0060] 1) The currently available thread pool after creation refers to all thread pools that can be used after it is determined that a new thread pool can be created and successfully created. The new thread pool is used together with the original thread pool to execute concurrent tasks and improve data processing efficiency.

[0061] Specifically, when the second judgment result is yes, the controller uses the created currently available thread pool to perform multi-threaded concurrent processing on the data to be processed, and recycles the created currently available thread pool after the processing of the data to be processed is completed.

[0062] The technical solution of this embodiment can monitor the system resource usage in real time and intelligently adjust the thread pool size through dynamic management of the thread pool, thereby achieving efficient concurrent processing effects and avoiding excessive consumption and waste of resources.

[0063] In an optional manner, the thread pool management method further includes: when the first judgment result is no, using a single thread pool to process the data to be processed.

[0064] like Figure 2As shown, in this embodiment, when a collection of multiple data is used as the data to be processed, single-thread processing is used under the premise that multi-thread processing is not required and the corresponding processing method is thread-safe. First, the data to be processed is split to obtain multiple subtasks corresponding to the split data to be processed, and multiple subtasks are executed sequentially until all the data to be processed are processed. After each subtask is executed, the next executable task to be processed is searched cyclically. If it is found, the next subtask to be executed in the data to be processed is executed, and finally the request result is generated.

[0065] Specifically, the controller further uses a single thread pool to process the data to be processed when the first judgment result is no, thereby improving the efficiency of processing small-scale data and avoiding the resource overhead caused by creating multiple thread pools for small-scale data, thereby achieving rational use of resources.

[0066] In an optional manner, the thread pool management method also includes: if the number of currently available thread pools meets the number of thread pools required by the data to be processed, using the currently available thread pools with the number of thread pools required by the data to be processed, performing multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, recycling management of the currently available thread pools.

[0067] like Figure 2 As shown, in this embodiment, when a collection of multiple data is used as the data to be processed, when multi-threaded processing is required and the corresponding processing method is thread-safe, when the data to be processed passed into the thread pool manager does not meet the set range requirements, that is, the number of currently available thread pools meets the number of thread pools required for the data to be processed, the currently available thread pool in the default created thread pool manager is used to concurrently process requests.

[0068] The process of concurrently processing requests includes:

[0069] Split the data to be processed into multiple independently executable subtasks. Submit all subtasks to the currently available thread pool, put them into the queue of the currently available thread pool, and wait for thread execution.

[0070] The thread pool assigns tasks to idle threads based on internal mechanisms (such as the number of core threads, the maximum number of threads, the capacity of the task queue, etc.). If the number of currently available thread pools meets the demand, then these threads will directly take the tasks from the queue and execute them. The threads assigned to the tasks begin to execute concurrently. Each thread processes tasks independently and executes instructions in the logical order of the tasks. Since multiple threads run at the same time, multi-threaded concurrent processing is achieved.

[0071] During the task execution process, the system can monitor the execution status of the task, including the number of completed tasks, the number of tasks being executed, the task execution time, etc., to understand the progress and performance of the task execution. When the thread completes the execution of the task, it will return the result to the caller or directly end the execution as needed. The system collects and processes the returned results. After all tasks are executed, the system will recycle the thread pool.

[0072] Specifically, the controller further reduces the number of times the thread pool is created and destroyed by directly utilizing existing thread pool resources, thereby improving the reuse rate of the thread pool and reducing the consumption of system resources.

[0073] In an optional manner, when the second judgment result is no, the currently available thread pool is used to process the data to be processed, and after the processing of the data to be processed is completed, the currently available thread pool is recycled and managed.

[0074] like Figure 2 As shown in the figure, when the current server resources do not support the dynamic creation of thread pools, a single thread is used by default to process the data to be processed in sequence. After all tasks are completed, the system will recycle the thread pool.

[0075] It should be noted that when the current server resources do not support the dynamic creation of thread pools, multi-threaded concurrent processing can also be used to process pending data. Assuming that there are 3 thread pools available now, when 5 requests are concurrently issued at the same time, the first 3 requests will use the 3 available thread pools respectively. When the 4th request tries to obtain it, there are two situations: one is that the previous 3 requests have been processed and released, so the reusable thread pool can be obtained at this time; the other is that if it is not released, the system will execute waiting. If the reusable thread pool is not obtained within the specified waiting time, it will be processed in a single-threaded manner. Here, because it is considered that the request waiting time is too long when there is no thread pool, which affects the processing time of the entire request, single-thread processing is used by default.

[0076] Specifically, when resources are tight, the controller further uses existing thread pool resources to process tasks in priority, thereby avoiding further resource shortages caused by creating a new thread pool and ensuring stable operation of the system.

[0077] In an optional manner, the step of performing recycling management on any thread pool includes:

[0078] It is determined whether any thread pool is a newly created thread pool to obtain a third determination result.

[0079] When the third judgment result is yes, close any thread pool and release resources; when the third judgment result is no, set any thread pool as an available thread pool for reuse.

[0080] like Figure 2 As shown, according to the corresponding custom attributes in the thread pool, it is determined whether the thread pool is a dynamically created thread pool. If the thread pool is a dynamically created thread pool, the thread pool is closed and resources are released. If the thread pool is not a dynamically created thread pool, the thread pool is recycled and placed in the thread pool management queue for reuse.

[0081] Specifically, the controller further implements intelligent recycling management of thread pools. For newly created thread pools, it closes and releases resources in a timely manner after the task is completed, avoiding long-term occupation of resources. For non-newly created thread pools, the number of times the thread pool is created and destroyed is reduced through reuse, thereby improving resource utilization efficiency.

[0082] It should be noted that when judging whether there is an available thread pool, the token bucket algorithm is used to judge, the thread pool is initialized according to system requirements, and parameters such as the number of core threads, the maximum number of threads, and the task queue are set. Before the thread pool executes a task, the tryAcquire method of the token bucket is first called to try to obtain a token. If tryAcquire returns true, it means that the token is successfully obtained and the thread pool task can continue to be executed. If tryAcquire returns false, it is processed according to the specific implementation strategy (such as rejecting the task, waiting for a period of time and then trying again). Once the token is obtained and access to the thread pool is allowed, the task is submitted to the thread pool to execute the task until all tasks are completed. Among them, when a thread or request needs to access the thread pool, it will try to obtain a token from the token bucket. If there are enough tokens in the token bucket (tokens>0), a token (tokens--) is consumed and access is allowed. If there are not enough tokens, the access request is rejected or put into the waiting queue.

[0083] like Figure 2 As shown, in this embodiment, under the condition that multi-thread concurrent processing of the data to be processed is required, there is no available thread pool, and dynamic creation of the thread pool is supported, the overall implementation process is as follows:

[0084] When a collection of multiple data is used as the data to be processed, when multi-threaded processing is required and the corresponding processing method is thread-safe, when the data to be processed enters the thread pool manager, it will first be judged according to the amount of data that needs to be processed. When the amount of data is greater than the set range that meets the big data requirement, a thread pool with a larger capacity will be dynamically created to process this request. On the contrary, if the amount of data does not meet the set range requirement, the thread pool in the default created thread pool manager will be used to process this request. At this time, it is assumed that the amount of data does not meet the big data range requirement, so it is necessary to obtain a thread pool from the thread pool manager. First, you need to try to obtain a token from the token bucket (whether the token can be obtained determines whether there is an available thread pool at present). When the token is not obtained, it proves that there is no available thread pool. At this time, the JVM usage rate, the server CPU usage rate, and the server memory usage rate are used to determine whether the dynamic creation of the thread pool is supported. When the dynamic creation of the thread pool is supported, a new thread pool is dynamically created based on the difference between the total number of thread pools required and the total number of available thread pools, and passed to the thread pool manager for acquisition. When the thread pool is obtained, the corresponding thread-safe data processing method is executed through dynamic proxy (dynamic proxy call is realized through reflection according to the class name and method name corresponding to the processing method passed in this request). After the method is executed, the dynamicCreate property value corresponding to the current thread pool is determined. Because the current thread pool is a dynamically created thread pool, the dynamicCreate property value is true, so this thread pool will be directly deregistered.

[0085] like Figure 3 As shown, the thread pool dynamic proxy layer includes: a dynamic executor, a resource controller, a resource extender, and a resource recycler.

[0086] ① Dynamic executor: The dynamic executor of this embodiment is different from the traditional multi-threaded concurrent execution technology. The dynamic executor of this embodiment provides a flexible dynamic method calling function. This allows developers to focus on the logical implementation of the target method without having to deeply understand the underlying operation of the thread pool. The executor simplifies the concurrent transformation process, making the processing of high-concurrency tasks more efficient and intuitive.

[0087] ② Resource controller: By adopting a thread-safe token bucket algorithm, the resource controller can accurately count resource consumption of requests. This not only makes monitoring resource consumption more convenient, but also provides real-time and accurate data support for resource expansion decisions.

[0088] ③ Resource Expander: Based on intelligent algorithms, the resource expander can determine whether it is necessary to dynamically expand thread pool resources based on the current maximum available resources of the system. This innovative function effectively prevents system crashes caused by excessive use of thread pool resources and ensures high availability and stability of the system.

[0089] ④ Resource Recycler: Different from the traditional thread pool management, the resource recycler of this embodiment introduces the attribute tag of "whether dynamically created". This allows the dynamically expanded thread pool resources to be recycled immediately after use, and the initialized thread pool resources can be retained in the queue for subsequent reuse, thereby greatly improving the utilization efficiency of resources.

[0090] Specifically, through thread management, not only the allocation and use of thread resources are fully optimized, but also the burden of concurrent programming on developers is greatly reduced, allowing developers to focus more on the implementation of business logic. While improving system performance and stability, it also achieves further improvement in software development efficiency.

[0091] Figure 4 FIG. 2 is a schematic diagram showing a structure of an embodiment of a thread pool management system 200 provided by the present invention. Figure 4 As shown, the system 200 includes: a first judgment module 210 , a second judgment module 220 and a first execution module 230 .

[0092] The first judgment module 210 is used to: determine whether to perform multi-thread concurrent processing on the data to be processed based on the size of the data to be processed, and obtain a first judgment result;

[0093] The second judgment module 220 is used to: when the first judgment result is yes, if the number of currently available thread pools does not meet the number of thread pools required for the data to be processed, determine whether a new thread pool can be created according to the server resource utilization rate to obtain a second judgment result;

[0094] The first execution module 230 is used for: when the second judgment result is yes, using the created currently available thread pool to perform multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, recycling management of the created currently available thread pool.

[0095] In an optional manner, the thread pool management system further includes: a second execution module.

[0096] The second execution module is used for: when the first judgment result is no, using the single thread pool to process the data to be processed.

[0097] In an optional manner, the thread pool management system further includes: a third execution module.

[0098] The third execution module is used for: if the number of currently available thread pools meets the number of thread pools required by the data to be processed, using the currently available thread pools with the number of thread pools required by the data to be processed, to perform multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, recycling management of the currently available thread pools.

[0099] The technical solution of this embodiment can monitor the system resource usage in real time and intelligently adjust the thread pool size through dynamic management of the thread pool, thereby achieving efficient concurrent processing effects and avoiding excessive consumption and waste of resources.

[0100] The above parameters and steps for each module to implement corresponding functions in the thread pool management system 200 of this embodiment can refer to the parameters and steps in the embodiment of the thread pool management method above, and will not be repeated here.

[0101] like Figure 5 As shown, an electronic device 300 of an embodiment of the present invention includes a processor 320, the processor 320 is coupled to a memory 310, and the memory 310 stores at least one computer program 330, and the at least one computer program 330 is loaded and executed by the processor 320, so that the electronic device 300 implements any of the above-mentioned thread pool management methods, specifically:

[0102] The electronic device 300 may have relatively large differences due to different configurations or performances, and may include one or more processors 320 (Central Processing Units, CPU) and one or more memories 310, wherein at least one computer program 330 is stored in the one or more memories 310, and the at least one computer program 330 is loaded and executed by the one or more processors 320, so that the electronic device 300 implements any thread pool management method provided in the above embodiments. Of course, the electronic device 300 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output, and the electronic device 300 may also include other components for implementing device functions, which will not be repeated here.

[0103] A computer-readable storage medium according to an embodiment of the present invention stores at least one computer program, and the at least one computer program is loaded and executed by a processor so that a computer implements any of the above-mentioned thread pool management methods.

[0104] Optionally, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.

[0105] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes any of the above-mentioned thread pool management methods.

[0106] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects and represent the definition of a specific order or sequence. The order of use of similar objects can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than the order shown or described.

[0107] Those skilled in the art know that the present invention can be implemented as a system, method or computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, namely: it can be complete hardware, it can be complete software (including firmware, resident software, microcode, etc.), or it can be a combination of hardware and software, which is generally referred to as "circuit", "module" or "system" herein. In addition, in some embodiments, the present invention can also be implemented in the form of a computer program product in one or more computer-readable media, and the computer-readable medium contains computer-readable program code.

[0108] Any combination of one or more computer-readable media may be used. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, device, or device.

[0109] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A thread pool management method, characterized in that: include: Based on the size of the data to be processed, determining whether to perform multi-thread concurrent processing on the data to be processed, and obtaining a first determination result; When the first judgment result is yes, if the number of currently available thread pools does not meet the number of thread pools required by the data to be processed, then judging whether a new thread pool can be created according to the server resource utilization rate, and obtaining a second judgment result; When the second judgment result is yes, the created currently available thread pool is used to perform multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, the created currently available thread pool is recycled.

2. The thread pool management method according to claim 1, characterized in that: Also includes: When the first judgment result is no, the data to be processed is processed using a single thread pool.

3. The thread pool management method according to claim 1, characterized in that: Also includes: If the number of currently available thread pools meets the number of thread pools required by the data to be processed, the currently available thread pools with the number of thread pools required by the data to be processed are used to perform multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, the currently available thread pools are recycled.

4. The thread pool management method according to claim 1, characterized in that: Also includes: When the second judgment result is no, the currently available thread pool is used to process the data to be processed, and after the processing of the data to be processed is completed, the currently available thread pool is recycled.

5. The thread pool management method according to any one of claims 1 to 4, characterized in that: The steps for recycling management of any thread pool include: Determine whether any of the thread pools is a newly created thread pool, and obtain a third determination result; When the third judgment result is yes, close any one of the thread pools and release resources; when the third judgment result is no, set any one of the thread pools as an available thread pool for reuse.

6. A thread pool management system, characterized in that: include: A first judgment module, a second judgment module and a first execution module; The first judgment module is used to: judge whether to perform multi-thread concurrent processing on the data to be processed based on the size of the data to be processed, and obtain a first judgment result; The second judgment module is used to: when the first judgment result is yes, if the number of currently available thread pools does not meet the number of thread pools required by the data to be processed, determine whether a new thread pool can be created according to the server resource utilization rate to obtain a second judgment result; The first execution module is used for: when the second judgment result is yes, using the created currently available thread pool to perform multi-threaded concurrent processing on the data to be processed, and after the processing of the data to be processed is completed, recycling management of the created currently available thread pool.

7. The thread pool management system according to claim 6, characterized in that: Also includes: A second execution module; The second execution module is used for: when the first judgment result is no, using a single thread pool to process the data to be processed.

8. The thread pool management system according to claim 6, characterized in that: Also includes: a third execution module; The third execution module is used to: if the number of currently available thread pools meets the number of thread pools required by the data to be processed, use the currently available thread pools with the number of thread pools required by the data to be processed to perform multi-threaded concurrent processing on the data to be processed, and recycle the currently available thread pools after the processing of the data to be processed is completed.

9. An electronic device, characterized in that: The electronic device includes a processor, the processor is coupled to a memory, the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor so that the electronic device implements the thread pool management method as described in any one of claims 1 to 5.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by the processor, so that the computer-readable storage medium implements the thread pool management method according to any one of claims 1 to 5.