Task processing method and system based on multi-thread fusion management
By uniformly managing thread pool resources in mobile applications, the problems of waste and conflict between thread pool resources between SDKs are solved, thread scheduling efficiency is improved, system lag is reduced, and user experience is improved.
Patent Information
- Application Number
- CN202411101185.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-12-10
AI Technical Summary
In mobile applications, different SDKs create thread pool processing tasks, resulting in waste and conflict of thread pool resources, which reduces system performance and affects user experience.
By obtaining the associated attribute information of system tasks, adding it to the pre-built native thread pool and custom thread pool, managing thread pool resources in a unified manner, avoiding resource preemption, and improving thread scheduling efficiency.
It realizes efficient and reasonable utilization of thread resources, reduces system lag problems, and improves user experience and application performance.
Smart Images

Figure CN119105848A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a task processing method and system based on multi-threaded fusion management. Background Art
[0002] At present, as the functions of mobile applications become more and more complex, the tasks that applications need to handle simultaneously are also becoming more and more onerous. When an application handles multiple tasks at the same time, it needs to run multiple threads concurrently, such as network requests, data processing, UI updates, etc. During the development process of an application, it is usually connected to many SDKs (Software Development Kits), and the SDK creates various thread pools to manage the concurrent tasks that the SDK is responsible for.
[0003] However, during the processing of related concurrent tasks, different SDKs will each create a thread pool to handle the tasks they are responsible for. The multi-threaded management of multiple SDKs is mixed together, which can easily lead to waste and conflict of thread pool resources, thereby reducing the application performance of the system, causing lag problems, and affecting the user experience. Summary of the invention
[0004] The embodiment of the present application provides a task processing method and system based on multi-threaded fusion management, which can process tasks through multi-threaded fusion management and solve the waste and conflict problems of thread pool resources during task processing.
[0005] In a first aspect, an embodiment of the present application provides a task processing method based on multi-thread fusion management, including:
[0006] When a newly triggered system task is received, associated attribute information of the system task is obtained, where the associated attribute information identifies the thread pool to which the system task belongs;
[0007] Adding the system task to the target thread pool based on the associated attribute information. The target thread pool includes a native thread pool and multiple custom thread pools. The custom thread pools are pre-created corresponding to different associated attribute information. The custom thread pools are obtained by modifying the calling class code of the native thread pool.
[0008] The task thread pre-built based on the target thread pool processes system tasks.
[0009] In a second aspect, an embodiment of the present application provides a task processing system based on multi-thread fusion management, including:
[0010] an acquisition module, configured to acquire, upon receiving a newly triggered system task, associated attribute information of the system task, wherein the associated attribute information identifies a thread pool to which the system task belongs;
[0011] Add a module, configured to add the system task to the target thread pool based on the associated attribute information, the target thread pool includes a native thread pool and multiple custom thread pools, the custom thread pools are pre-created corresponding to different associated attribute information, and the custom thread pools are obtained by modifying the calling class code of the native thread pool;
[0012] The processing module is configured to process system tasks based on task threads pre-built in the target thread pool.
[0013] In a third aspect, an embodiment of the present application provides a task processing device based on multi-thread fusion management, including:
[0014] memory and one or more processors;
[0015] The memory is configured to store one or more programs;
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the task processing method based on multi-thread fusion management as described in the first aspect.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer-executable instructions, and when the computer-executable instructions are executed by a computer processor, they are configured to execute the task processing method based on multi-threaded fusion management as described in the first aspect.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed on a computer or a processor, the computer or the processor executes the task processing method based on multi-thread fusion management as described in the first aspect.
[0019] The embodiment of the present application obtains the associated attribute information of the system task when receiving a newly triggered system task, and the associated attribute information identifies the thread pool to which the system task belongs; based on the associated attribute information, the system task is added to the target thread pool, the target thread pool includes a native thread pool and multiple custom thread pools, the custom thread pool is pre-created corresponding to different associated attribute information, and the custom thread pool is obtained by modifying the calling class code of the native thread pool; the system task is processed based on the task thread pre-constructed in the target thread pool. By adopting the above technical means, a custom thread pool is constructed by modifying the calling class code of the native thread pool, and then the newly triggered system task is added to the native thread pool or the custom thread pool for processing, so that efficient and reasonable thread scheduling and task processing can be performed through the uniformly managed custom thread pool, avoiding thread pool preemption of resources, making reasonable use of processor resources, thereby reducing system freeze problems and improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a flowchart of a task processing method based on multi-thread fusion management provided by an embodiment of the present application;
[0021] Figure 2 It is a schematic diagram of modification of the native thread calling class code in the embodiment of the present application;
[0022] Figure 3 is a flow chart of allocation of system tasks in an embodiment of the present application;
[0023] Figure 4 It is a schematic diagram of thread pool allocation of system tasks in an embodiment of the present application;
[0024] Figure 5 It is a structural diagram of a task processing system based on multi-thread fusion management provided by an embodiment of the present application;
[0025] Figure 6 It is a structural diagram of a task processing device based on multi-threaded fusion management provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0027] The task processing method based on multi-thread fusion management provided in this application aims to optimize the processing of concurrent tasks in mobile applications by fusion management of multiple threads, especially when multiple SDKs are used together, effectively reduce the waste and conflict of thread pool resources, improve application performance, and improve user experience.
[0028] In the relevant mobile application task processing scenarios, as the functions of mobile applications become increasingly complex and user experience requirements increase, applications often need to handle multiple tasks at the same time, and there will be many threads running concurrently, such as network requests, data processing, UI updates, etc. In order to ensure the fluency of the application and the timeliness of the response, the reasonable management and use of multithreading has become a vital task. During the application development process, many SDKs need to be connected. Most SDKs have their own concurrent tasks to be processed, so the SDK will manage its own concurrent tasks through various thread pools. Since different SDKs generally create their own thread pools, this will lead to waste and conflict of thread pool resources between different SDKs, reducing application performance. Since the scale of SDKs relied on in the engineering code is very large, the multi-thread management of many SDKs is mixed together, which causes very chaotic thread execution. According to statistics, there are as many as 200 threads and thread pools in a live broadcast application. Such chaotic thread management will not only cause additional resource waste due to frequent thread creation, thread switching, and thread destruction, but also cause child threads to occupy too much CPU resources, making it impossible for the main thread to seize CPU resources, resulting in application unresponsiveness and lag problems.
[0029] The relevant multi-threaded optimization solutions generally only manage the threads within the project, and use a unified thread pool for the project's own code to improve the performance of thread scheduling. It is impossible to optimize the threads and thread pools in the large number of SDKs introduced into the project code. Since the SDKs that the business relies on are rich in variety and from various sources, and the code implementation in the SDK often cannot be modified by conventional means, it is only possible to optimize the thread pool of the project code itself. However, the thread pool in the project code will still compete with the thread pool in the SDK for resources, resulting in the thread call at the application level is still disorganized and inefficient.
[0030] To this end, a task processing method based on multi-threaded fusion management is provided in an embodiment of the present application. By uniformly managing the thread pool in the SDK and engineering code, thread utilization is improved, resource occupation is reduced, application performance is optimized, and the waste and conflict problems of thread pool resources in the task processing process are solved.
[0031] Example:
[0032] Figure 1A flowchart of a task processing method based on multi-thread fusion management provided by an embodiment of the present application is given. The task processing method based on multi-thread fusion management provided in this embodiment can be executed by a task processing device based on multi-thread fusion management. The task processing device based on multi-thread fusion management can be implemented by software and / or hardware. The task processing device based on multi-thread fusion management can be composed of two or more physical entities, or it can be composed of one physical entity. Generally speaking, the task processing device based on multi-thread fusion management can be a mobile terminal device such as a mobile phone or a tablet.
[0033] The following description is made by taking the task processing device as an example to execute the task processing method based on multi-thread fusion management. Figure 1 , the task processing method based on multi-thread fusion management specifically includes:
[0034] S110. When a newly triggered system task is received, associated attribute information of the system task is obtained, where the associated attribute information identifies a thread pool to which the system task belongs.
[0035] This application establishes a flexible thread pool management mechanism by uniformly managing and optimizing thread pool resources in applications, integrating thread pools originally managed by different SDKs into a unified framework to achieve sharing and efficient use of thread resources. When processing system tasks, by selecting the corresponding thread pool, efficient and smooth execution of system tasks can be achieved.
[0036] After receiving the system task, the associated attribute information of the system task is first determined. The associated attribute information indicates the thread pool to which the current system task belongs. Through the associated attribute information, the task thread provided by the corresponding thread pool can be found to process the system task.
[0037] Prior to this, the various system tasks in the application are classified to clarify which tasks belong to categories such as network requests, IO data processing, and UI updates. According to different task categories, the associated attribute information can be defined, and this attribute information is used to identify the task category information of the system task. According to actual needs, the associated attribute information can also include information such as the belonging list, processing priority, and required thread resources, and serve as the basis for assigning tasks to different thread pools. After triggering a new system task, the system task can be further assigned and processed by determining the associated attribute information.
[0038] S120. Add the system task to the target thread pool based on the associated attribute information. The target thread pool includes a native thread pool and multiple custom thread pools. The custom thread pools are pre-created corresponding to different associated attribute information. The custom thread pools are obtained by modifying the calling class code of the native thread pool.
[0039] In order to assign a thread pool with unified management and scheduling to system tasks, it is necessary to take over all the threads and thread pools of the SDK that the project code depends on and the thread pools within the project code through AOP (Aspect-Oriented Programming, which is a programming method that aims to improve the modularity of code by separating cross-cutting concerns) during the compilation phase of the application, so as to achieve unified scheduling of thread resources, thereby more reasonably handling multi-threaded task concurrency and making reasonable use of CPU resources.
[0040] Among them, the creation and execution process of threads and thread pools is taken over by AOP means, replaced by the creation and execution of threads or thread pools of custom classes, and the newly created thread pool is defined as a custom thread pool. Later, in the code running stage, thread pool resources can be reasonably allocated to achieve the effect of orderly execution of system tasks by threads.
[0041] The process of creating a custom thread pool includes:
[0042] During the application compilation phase, the code data associated with the native thread pool in the software development kit and application engineering code is scanned, the calling class code in the code data is modified according to the set calling thread information, and the modified software development kit and application engineering code are packaged to obtain a custom thread pool.
[0043] During the application compilation phase, custom creation of the thread pool can be achieved by modifying the code of the system's native thread pool and changing the calling class code in its code data to the corresponding calling class in the custom thread pool.
[0044] Specifically, the ASM bytecode modification tool is used to scan all the codes that use threads and thread pools in the SDK and project codes, that is, the code data associated with the native thread pool, and then the code data can be modified. ASM is a lightweight, high-performance Java bytecode manipulation framework that can be used to generate new classes, modify existing classes, or extract information from class files. ASM operates on JVM bytecode and provides a low-level API to directly operate bytecode instructions. It is an important tool for AOP aspect-oriented programming.
[0045] Furthermore, the calling class code in the code data is modified according to the set calling thread information, including:
[0046] The replacement code is constructed based on the set calling thread information, and the calling class code in the code data is replaced with the replacement code using a bytecode modification tool.
[0047] When modifying the calling class code, you need to change the code in the native thread pool to the corresponding calling class code in the custom thread pool, which is defined as the replacement code. Figure 2 According to the thread usage of different SDKs, the ASM bytecode modification tool is used to scan the calling class codes used by these threads and thread pools, and then the corresponding code calls are converted into custom code calls.
[0048] For example, Figure 2 As shown in the figure, the calling class code ProxyThreadExecutor, new Thread() and newThreadPoolExecutor() can be directly or indirectly replaced with the call in ProxyThreadExecutor. And new SchedulerThreadPoolExecutor() needs to be replaced with the call of the custom replacement code ProxySchedulerThreadExecutor(). You only need to replace the calling class code with the corresponding replacement code, and then package the modified SDK and project code into an apk application installation package to complete the construction of the custom thread pool.
[0049] Take the example of changing the calling class code new ThreadPoolExecutor() to the replacement code newProxyThreadExecutor().
[0050] The bytecode representation of new ThreadPoolExecutor() is:
[0051] Code:
[0052] 0:new#2 / / class java / util / concurrent / ThreadPoolExecutor
[0053] 3:dup
[0054] 4:iconst_1
[0055] 5:iconst_1
[0056] 6:lconst_0
[0057] 7:getstatic#3 / / Field java / util / concurrent / TimeUnit.MILLISECONDS:Ljava / util / concurrent / TimeUnit;
[0058] 10:new#4 / / class java / util / concurrent / LinkedBlockingQueue
[0059] 13:dup
[0060] 14:invokespecial#5 / / Method java / util / concurrent / LinkedBlockingQueue." <init>":()V
[0061] 17:invokespecial#6 / / Method java / util / concurrent / ThreadPoolExecutor." <init>":(IIJLjava / util / concurrent / TimeUnit;Ljava / util / concurrent / BlockingQueue;)V
[0062] 20:pop
[0063] If you need to replace new ThreadPoolExecutor() with newProxyThreadPoolExecutor() through bytecode modification, you need to modify the task input parameters in lines 0 and 17 and replace the input parameters with the ProxyThreadPoolExecutor class. This replacement process is performed through the ASM bytecode modification tool. After the replacement, the generated apk will call new ProxyThreadPoolExecutor() to process system tasks instead of new ThreadPoolExecutor(), thereby completing the construction of the custom thread pool.
[0064] It should be noted that, according to actual usage, for some native thread pools that cannot be modified, the original calling class code is retained for subsequent calls to the native thread pool.
[0065] Optionally, all code locations that use threads and thread pools in the SDK and project code are scanned by ASM, and thread pools in which the substitute class code is modified are collected during the compilation phase to generate a list. A whitelist or blacklist can be configured based on this list file later. When a system task calls a thread in a whitelist thread pool, the system task is placed in the corresponding thread pool in the whitelist for processing. If a thread pool in the blacklist is called, the system task is placed in the native thread pool for processing.
[0066] Optionally, the process of creating a custom thread pool also includes:
[0067] Obtain processor core information and performance parameters of the current device, configure quantity information of a custom thread pool based on the processor core information and performance parameters, and create a custom thread pool based on the quantity information.
[0068] It is understandable that the number of custom thread pools should be sufficient to fully utilize the parallel processing capabilities of the processor, but not too many to avoid excessive resource competition. Therefore, it is necessary to configure the appropriate number of custom thread pools based on the number of processor cores and other related device performance parameters to reasonably and fully utilize system resources.
[0069] Optionally, the size of the thread pool can also be dynamically adjusted according to the application load by monitoring the performance indicators of the thread pool (such as task queue length, thread activity, etc.) and increasing or decreasing the number of threads accordingly to optimize the system's resource management.
[0070] After completing the construction of the above custom thread pool, during the code running stage, the corresponding thread pool will be allocated to process the system task according to the associated attribute information of the triggered system task.
[0071] Among them, refer to Figure 3 , adding system tasks to the target thread pool based on associated attribute information, including:
[0072] S1201, judging whether the thread pool to which the system task belongs is in a preset whitelist based on the associated attribute information;
[0073] S1202. If the thread pool to which the system task belongs is not in the whitelist, add the system task to the native thread pool; if the thread pool to which the system task belongs is in the whitelist, add the system task to the corresponding custom thread pool.
[0074] Exemplarily, based on the above-mentioned pre-built custom thread pool, the corresponding thread pool is selected to process the system task through the associated attribute information. As mentioned above, all codes using threads and thread pools will be scanned out during the compilation phase, and a manifest file will be generated, and then a whitelist will be built based on the manifest file. Based on the whitelist, if it is determined that the thread pool to which the system task identified by the associated attribute information belongs is in the whitelist, the system task will be handed over to the custom thread pool for processing; conversely, if it is not in the whitelist, it means that the thread pool has not been modified and needs to be handed over to the native thread pool for processing to ensure the normal execution of the system task.
[0075] Optionally, before adding the system task to the corresponding custom thread pool, the following steps are also included:
[0076] When it is determined that the thread pool to which the system task belongs is a single-threaded thread pool, the system task is added to the native thread pool.
[0077] It should be noted that single-threaded thread pools are generally used to handle special businesses, which have timing requirements in their businesses, that is, all tasks generally have a sequence, and the first-come-first-served is executed. In this case, if it is replaced with a unified thread pool, there will be timing problems, so in this case, the native thread pool is still used to execute tasks.
[0078] Reference Figure 4 , add system tasks to the corresponding custom thread pool, including:
[0079] Determine the task type of the system task, and add the system task to the corresponding custom thread pool according to the task type.
[0080] For non-single-thread thread pools in the whitelist, select the corresponding thread pool for processing based on the task type of the system task. Figure 4 As shown, by judging whether the task type is an IO task, if it is an IO task, a custom IO thread pool is used to process the task. If it is not an IO task, it is judged whether it is a network task. If it is a network task, a custom network thread pool needs to be used to process the task. If it is not a network task, a custom BG thread pool is used to process the task. The BG thread pool is used to process all non-single-threaded, non-IO, and non-network tasks. According to actual needs, the number and type of thread pools can also be adaptively increased. This application does not impose fixed restrictions on the construction of specific custom thread pools, and will not be elaborated here.
[0081] By bringing all SDK threads and thread pools into the unified processing logic mentioned above, the use of all threads and thread pools in the application can be managed in a unified way, thereby solving the problem of multiple SDKs and multiple thread pools competing for CPU resources, which leads to the decline in the performance of the entire application, improving the system task processing efficiency, and optimizing the user experience.
[0082] S130, processing system tasks based on the task threads pre-constructed in the target thread pool.
[0083] Finally, according to the target thread pool determined above, after receiving the system task, the target thread pool executes the task according to its own scheduling strategy. Each thread pool can independently configure parameters such as the number of threads, thread priority, and task queue length to adapt to different task requirements. In addition, the system also monitors the running status of the thread pool in real time, including the task queue length, thread activity, resource utilization, etc. According to the monitoring results, the thread pool configuration is dynamically adjusted, such as increasing or decreasing the number of threads, to optimize performance.
[0084] Optionally, during the task execution, the system can capture and handle possible exceptions, such as network errors, data parsing errors, etc. For retryable tasks, retries are performed according to the preset retry strategy; for failed tasks, necessary rollback operations are performed to ensure data consistency and application stability.
[0085] By using AOP aspect-oriented programming, ASM bytecode instrumentation and other methods, the engineering code can automatically replace the calling code of threads and thread pools during the compilation stage, and normalize the use of threads and thread pools to a customized unified thread pool. When the application is running online later, the thread pool is managed based on the multi-SDK thread pool fusion solution of this application to process system business. In this way, it is possible to reduce the repeated creation of threads in the application, reduce the number of threads running in memory at the same time, reduce the competition for a small amount of CPU resources by a large number of concurrent threads, improve the CPU execution efficiency, and increase the utilization rate of the system main thread on the CPU, thereby reducing freezes and unresponsiveness.
[0086] In the above, when a newly triggered system task is received, the associated attribute information of the system task is obtained, and the associated attribute information identifies the thread pool to which the system task belongs; based on the associated attribute information, the system task is added to the target thread pool, and the target thread pool includes a native thread pool and multiple custom thread pools, and the custom thread pool is pre-created corresponding to different associated attribute information, and the custom thread pool is obtained by modifying the calling class code of the native thread pool; the system task is processed based on the task thread pre-built in the target thread pool. Using the above technical means, a custom thread pool is constructed by modifying the calling class code of the native thread pool, and then the newly triggered system task is added to the native thread pool or the custom thread pool for processing, so that through the uniformly managed custom thread pool, efficient and reasonable thread scheduling and task processing can be performed, avoiding thread pool preemption of resources, making reasonable use of processor resources, thereby reducing system freezes and improving user experience.
[0087] Based on the above embodiments, Figure 5 This is a schematic diagram of the structure of a task processing system based on multi-threaded fusion management provided by this application. Figure 5 The task processing system based on multi-thread fusion management provided in this embodiment specifically includes: an acquisition module 21, an adding module 22 and a processing module 23.
[0088] The acquisition module 21 is configured to, upon receiving a newly triggered system task, acquire the associated attribute information of the system task, wherein the associated attribute information identifies the thread pool to which the system task belongs;
[0089] An adding module 22 is configured to add the system task to a target thread pool based on the associated attribute information, wherein the target thread pool includes a native thread pool and a plurality of custom thread pools, wherein the custom thread pools are pre-created corresponding to different associated attribute information, and the custom thread pools are obtained by modifying a calling class code of the native thread pool;
[0090] The processing module 23 is configured to process the system task based on the task thread pre-constructed in the target thread pool.
[0091] Specifically, the process of creating a custom thread pool includes:
[0092] During the application compilation phase, the code data associated with the native thread pool in the software development kit and application engineering code is scanned, the calling class code in the code data is modified according to the set calling thread information, and the modified software development kit and application engineering code are packaged to obtain a custom thread pool.
[0093] The calling class code in the code data is modified according to the set calling thread information, including:
[0094] The replacement code is constructed based on the set calling thread information, and the calling class code in the code data is replaced with the replacement code using a bytecode modification tool.
[0095] In addition, the creation process of a custom thread pool also includes:
[0096] Obtain processor core information and performance parameters of the current device, configure quantity information of a custom thread pool based on the processor core information and performance parameters, and create a custom thread pool based on the quantity information.
[0097] Specifically, adding the system task to the target thread pool based on the associated attribute information includes:
[0098] Determine whether the thread pool to which the system task belongs is in a preset whitelist based on the associated attribute information;
[0099] If the thread pool to which the system task belongs is not in the whitelist, the system task is added to the native thread pool; if the thread pool to which the system task belongs is in the whitelist, the system task is added to the corresponding custom thread pool.
[0100] In addition, before adding the system task to the corresponding custom thread pool, it also includes:
[0101] When it is determined that the thread pool to which the system task belongs is a single-threaded thread pool, the system task is added to the native thread pool.
[0102] Specifically, add system tasks to the corresponding custom thread pool, including:
[0103] Determine the task type of the system task, and add the system task to the corresponding custom thread pool according to the task type.
[0104] In the above, when a newly triggered system task is received, the associated attribute information of the system task is obtained, and the associated attribute information identifies the thread pool to which the system task belongs; based on the associated attribute information, the system task is added to the target thread pool, and the target thread pool includes a native thread pool and multiple custom thread pools, and the custom thread pool is pre-created corresponding to different associated attribute information, and the custom thread pool is obtained by modifying the calling class code of the native thread pool; the system task is processed based on the task thread pre-built in the target thread pool. Using the above technical means, a custom thread pool is constructed by modifying the calling class code of the native thread pool, and then the newly triggered system task is added to the native thread pool or the custom thread pool for processing, so that through the uniformly managed custom thread pool, efficient and reasonable thread scheduling and task processing can be performed, avoiding thread pool preemption of resources, making reasonable use of processor resources, thereby reducing system freezes and improving user experience.
[0105] The task processing system based on multi-thread fusion management provided in the embodiment of the present application can be configured to execute the task processing method based on multi-thread fusion management provided in the above embodiment, and has corresponding functions and beneficial effects.
[0106] Based on the above embodiments, the present application also provides a task processing device based on multi-thread fusion management, referring to Figure 6 , the task processing device based on multi-thread fusion management includes: a processor 31, a memory 32, a communication module 33, an input device 34 and an output device 35. The memory, as a computer-readable storage medium, can be configured to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the task processing method based on multi-thread fusion management described in any embodiment of the present application (for example, the acquisition module, the addition module and the processing module in the task processing system based on multi-thread fusion management). The communication module is configured to perform data transmission. The processor executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory, that is, realizes the above-mentioned task processing method based on multi-thread fusion management. The input device can be configured to receive input digital or character information, and generate key signal input related to the user settings and function control of the device. The output device may include a display device such as a display screen. The task processing device based on multi-thread fusion management provided above can be configured to execute the task processing method based on multi-thread fusion management provided in the above-mentioned embodiment, and has corresponding functions and beneficial effects.
[0107] On the basis of the above embodiments, the embodiments of the present application also provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, wherein the computer-executable instructions are configured to execute a task processing method based on multi-thread fusion management when executed by a computer processor, and the storage medium can be any of various types of memory devices or storage devices. Of course, the computer-executable instructions of the computer-readable storage medium provided in the embodiments of the present application are not limited to the task processing method based on multi-thread fusion management as described above, and can also execute the related operations in the task processing method based on multi-thread fusion management provided in any embodiment of the present application.
[0108] On the basis of the above embodiments, the embodiments of the present application also provide a computer program product. The essence of the technical solution of the present application or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer program product is stored in a storage medium, including a number of instructions for enabling a computer device, a mobile terminal or a processor therein to execute all or part of the steps of the task processing method based on multi-threaded fusion management described in each embodiment of the present application.< / init> < / init>
Claims
1. A task processing method based on multi-threaded fusion management, characterized in that: include: When a newly triggered system task is received, obtaining associated attribute information of the system task, wherein the associated attribute information identifies a thread pool to which the system task belongs; Adding the system task to a target thread pool based on the associated attribute information, wherein the target thread pool includes a native thread pool and a plurality of custom thread pools, wherein the custom thread pools are pre-created corresponding to different associated attribute information, and the custom thread pools are obtained by modifying a calling class code of the native thread pool; The system task is processed based on the task thread pre-built in the target thread pool.
2. The task processing method based on multi-thread fusion management according to claim 1 is characterized in that: The creation process of the custom thread pool includes: During the application compilation stage, the code data associated with the native thread pool in the software development kit and the application engineering code is scanned, the calling class code in the code data is modified according to the set calling thread information, and the software development kit and application engineering code with the modified code are packaged to obtain the custom thread pool.
3. The task processing method based on multi-thread fusion management according to claim 2 is characterized in that: The modifying the calling class code in the code data according to the set calling thread information includes: The replacement code is constructed based on the set calling thread information, and a bytecode modification tool is used to replace the calling class code in the code data with the replacement code.
4. The task processing method based on multi-thread fusion management according to claim 2 is characterized in that: The creation process of the custom thread pool also includes: The processor core information and performance parameters of the current device are obtained, and the quantity information of the custom thread pool is configured based on the processor core information and the performance parameters, so as to create the custom thread pool based on the quantity information.
5. The task processing method based on multi-thread fusion management according to claim 1 is characterized in that: The adding the system task to the target thread pool based on the associated attribute information includes: Determining whether the thread pool to which the system task belongs is in a preset whitelist based on the associated attribute information; If the thread pool to which the system task belongs is not in the whitelist, adding the system task to the native thread pool; When the thread pool to which the system task belongs is in the whitelist, the system task is added to the corresponding custom thread pool.
6. The task processing method based on multi-thread fusion management according to claim 5 is characterized in that: Before adding the system task to the corresponding custom thread pool, the method further includes: When it is determined that the thread pool to which the system task belongs is a single-thread thread pool, the system task is added to the native thread pool.
7. The task processing method based on multi-thread fusion management according to claim 5 is characterized in that: Adding the system task to the corresponding custom thread pool includes: Determine the task type of the system task, and add the system task to the corresponding custom thread pool according to the task type.
8. A task processing system based on multi-threaded fusion management, characterized in that: include: an acquisition module, configured to, upon receiving a newly triggered system task, acquire associated attribute information of the system task, wherein the associated attribute information identifies a thread pool to which the system task belongs; An adding module is configured to add the system task to a target thread pool based on the associated attribute information, wherein the target thread pool includes a native thread pool and a plurality of custom thread pools, wherein the custom thread pools are pre-created corresponding to different associated attribute information, and the custom thread pools are obtained by modifying a calling class code of the native thread pool; The processing module is configured to process the system task based on the task thread pre-built in the target thread pool.
9. A task processing device based on multi-threaded fusion management, characterized in that: include: memory and one or more processors; The memory is configured to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the task processing method based on multi-thread fusion management as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which, when executed by a computer processor, are configured to execute the task processing method based on multi-thread fusion management as described in any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product includes instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes the task processing method based on multi-thread fusion management as described in any one of claims 1 to 7.
Citation Information
Cited By
Multi-thread driven communication centralized control method and system and electronic equipment
CN120128212A
A multi-threaded driven communication centralized control method, system and electronic equipment
CN120128212B
Static and dynamic fusion low-overhead multi-thread optimal configuration prediction method and system
CN120162163A
Tomcat container application thread pool isolation method and device based on Java Agent and medium
CN121918940A
