Method and device for preventing thread pool overflow, electronic equipment and storage medium
Patent Information
- Application Number
- CN202211029010.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-25
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2042-08-25
AI Technical Summary
[0002]随着信息技术的发展,针对大量的交易请求进行处理时,需要处理器具有较好的处理能力,在处理交易请求时,一般采用线程池的方式对提交到线程池的交易请求进行处理,线程池具有设定的核心线程数上限,该核心线程数上限可以表征该线程池的最大处理能力,当线程池处理的任务中有较多的异常任务,例如无反应的任务或者反馈较慢的任务,会严重影响到线程池的其他正常任务的处理
[0023]According to embodiments of this disclosure, transaction timeouts of transaction tasks in the thread pool are determined by generating transaction identification information. First timeout transaction tasks in the main thread pool are transferred to the slave thread queue, and second timeout transaction tasks in the slave thread pool are cleared. This ensures that all transaction tasks in the main thread pool are less than or equal to a first set timeout, and that all transaction tasks in the slave thread pool are less than or equal to a second set timeout. This effectively clears abnormal transaction tasks in both the main and slave thread pools in a timely manner, prevents thread pool overflow, and improves the normal processing capacity and efficiency of the thread pool.
Smart Images

Figure CN115373846B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and specifically to a method, apparatus, electronic device, and storage medium for preventing thread pool overflow. Background Technology
[0002] With the development of information technology, processing a large number of transaction requests requires processors with strong processing capabilities. Thread pools are commonly used to handle these requests. Each thread pool has a set maximum core thread count, which represents its maximum processing capacity. When a thread pool handles a large number of abnormal tasks, such as unresponsive or slow-responding tasks, it severely impacts the processing of other normal tasks. Current technologies, when a thread pool exceeds its core thread count (i.e., when it overflows), cannot process any more tasks and directly rejects the corresponding transaction requests. This results in a large number of abnormal tasks in the thread pool, preventing normal transaction tasks from returning correctly and causing inefficiency. Summary of the Invention
[0003] In view of this, the present disclosure provides a method, apparatus, electronic device and storage medium for preventing thread pool overflow, which can at least prevent thread pool overflow, ensure that the main thread pool handles normal transaction tasks, and handle transaction tasks with long transaction times from the secondary thread pool. By separating different tasks, the working efficiency of the thread pool can be effectively improved, while ensuring the processing of normal transaction tasks.
[0004] The first aspect of this disclosure provides a method for preventing overflow in a thread pool, the thread pool including a main thread pool and a slave thread pool, the method comprising: generating transaction identification information associated with a transaction task based on transaction feature information associated with a transaction request of the transaction task, the transaction identification information being used to determine the transaction timeout of the transaction task in the thread pool; in response to an instruction that the number of queues in the main thread queue is greater than a first preset number of queues, transferring a first timeout transaction task in the main thread pool to a slave thread queue, the main thread queue being associated with the main thread pool and the slave thread queue being associated with the slave thread pool, the transaction timeout of the first timeout transaction task being greater than a first preset duration; and in response to an instruction that the number of queues in the slave thread queue is greater than a second preset number of queues, removing a second timeout transaction task from the slave thread pool, the transaction timeout of the second timeout transaction task being greater than a second preset duration.
[0005] In some exemplary embodiments of this disclosure, generating transaction identification information associated with the transaction task based on transaction feature information associated with the transaction request of the transaction task includes: obtaining the transaction feature information associated with the transaction request of the transaction task; and processing the transaction feature information through a hash function to generate transaction identification information associated with the transaction task.
[0006] In some exemplary embodiments of this disclosure, the method further includes: after responding to an instruction that the number of queues in the main thread queue is greater than a first set number of queues, statistically analyzing the transaction time consumption of all transaction tasks in the main thread pool based on the transaction identification information, and generating a first statistical result; and determining a first timeout transaction task from all transaction tasks in the main thread pool based on the first statistical result and the first set duration.
[0007] In some exemplary embodiments of this disclosure, the method further includes: after responding to an instruction that the number of queues in the slave thread queue is greater than a second set number of queues, statistically analyzing the transaction time consumption of all transaction tasks in the slave thread pool based on the transaction identification information, and generating a second statistical result; and determining a second timeout transaction task from all transaction tasks in the slave thread pool based on the second statistical result and the second set duration.
[0008] In some exemplary embodiments of this disclosure, the step of transferring the first timed-out transaction task in the main thread pool to the slave thread queue includes: obtaining first processing information associated with the first timed-out transaction task in the main thread pool according to the determined first timed-out transaction task; and transferring the first timed-out transaction task and the first processing information to the slave thread queue of the slave thread pool.
[0009] In some exemplary embodiments of this disclosure, the method further includes: determining, based on the determined first timeout transaction task, a similar transaction task belonging to the same category as the first timeout transaction task from the main thread queue; and transferring the similar transaction task to the slave thread queue.
[0010] In some exemplary embodiments of this disclosure, the step of removing the second timed-out transaction task from the slave thread pool includes: determining second processing information associated with the second timed-out transaction task from the slave thread pool based on the determined second timed-out transaction task; and removing the second timed-out transaction task and the second processing information from the slave thread pool.
[0011] In some exemplary embodiments of this disclosure, the method further includes: periodically polling the transaction tasks from the thread pool and clearing transaction tasks whose transaction time exceeds a third set duration.
[0012] In a second aspect of this disclosure, a thread pool overflow prevention device is provided. The thread pool includes a main thread pool and a slave thread pool. The device includes: a generation module configured to generate transaction identification information associated with a transaction task based on transaction feature information associated with the transaction request of the transaction task, wherein the transaction identification information is used to determine the transaction time of the transaction task in the thread pool; a first response module configured to, in response to an instruction that the number of queues in the main thread queue is greater than a first set number of queues, transfer a first timed-out transaction task in the main thread pool to a slave thread queue, wherein the main thread queue is associated with the main thread pool and the slave thread queue is associated with the slave thread pool, and the transaction time of the first timed-out transaction task is greater than a first set duration; and a second response module configured to, in response to an instruction that the number of queues in the slave thread queue is greater than a second set number of queues, remove a second timed-out transaction task from the slave thread pool, wherein the transaction time of the second timed-out transaction task is greater than a second set duration.
[0013] In some exemplary embodiments of this disclosure, the generation module includes a generation unit configured to: acquire the transaction feature information associated with the transaction request of the transaction task; and process the transaction feature information through a hash function to generate transaction identification information associated with the transaction task.
[0014] In some exemplary embodiments of this disclosure, the thread pool overflow prevention device further includes a first statistics module, which is configured to: after responding to an instruction that the number of queues in the main thread queue is greater than a first set number of queues, perform statistics on the transaction time consumption of all transaction tasks in the main thread pool according to the transaction identification information, and generate a first statistical result; and determine a first timeout transaction task from all transaction tasks in the main thread pool according to the first statistical result and the first set duration.
[0015] In some exemplary embodiments of this disclosure, the thread pool overflow prevention device further includes a second statistics module, which is configured to: after responding to an instruction that the number of queues in the slave thread queue is greater than a second set number of queues, perform statistics on the transaction time of all transaction tasks in the slave thread pool based on the transaction identification information, and generate a second statistical result; and determine a second timeout transaction task from all transaction tasks in the slave thread pool based on the second statistical result and the second set duration.
[0016] In some exemplary embodiments of this disclosure, the first response module further includes a first response unit, which is configured to: obtain first processing information associated with the first timeout transaction task in the main thread pool according to the determined first timeout transaction task; and transfer the first timeout transaction task and the first processing information to the slave thread queue of the slave thread pool.
[0017] In some exemplary embodiments of this disclosure, the thread pool overflow prevention device further includes a determining module, which is configured to: determine, based on the determined first timeout transaction task, identify similar transaction tasks belonging to the same category as the first timeout transaction task from the main thread queue; and transfer the similar transaction tasks to the slave thread queue.
[0018] In some exemplary embodiments of this disclosure, the second response module further includes a second response unit, which is configured to: determine second processing information associated with the second timeout transaction task from the slave thread pool based on the determined second timeout transaction task; and clear the second timeout transaction task and the second processing information from the slave thread pool.
[0019] In some exemplary embodiments of this disclosure, the thread pool overflow prevention device further includes a timed polling module, which is configured to: periodically poll the transaction tasks from the thread pool and clear transaction tasks whose transaction time exceeds a third set time.
[0020] In a third aspect of this disclosure, an electronic device is provided, comprising: one or more processors; and a storage device for storing executable instructions that, when executed by the processor, implement the method described above.
[0021] In a fourth aspect of this disclosure, a computer-readable storage medium is provided having executable instructions stored thereon that, when executed by a processor, implement the method described above.
[0022] In a fifth aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method described above.
[0023] According to embodiments of this disclosure, transaction timeouts of transaction tasks in the thread pool are determined by generating transaction identification information. First timeout transaction tasks in the main thread pool are transferred to the slave thread queue, and second timeout transaction tasks in the slave thread pool are cleared. This ensures that all transaction tasks in the main thread pool are less than or equal to a first set timeout, and that all transaction tasks in the slave thread pool are less than or equal to a second set timeout. This effectively clears abnormal transaction tasks in both the main and slave thread pools in a timely manner, prevents thread pool overflow, and improves the normal processing capacity and efficiency of the thread pool. Attached Figure Description
[0024] The above and other objects, features and advantages of this disclosure will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0025] Figure 1 This illustration schematically shows an exemplary system architecture to which a thread pool overflow prevention method can be applied according to embodiments of the present disclosure;
[0026] Figure 2 A flowchart illustrating a method for preventing thread pool overflow according to an embodiment of the present disclosure is shown schematically.
[0027] Figure 3 This schematically illustrates a flowchart of the thread pool overflow prevention method according to an embodiment of the present disclosure during operation S210;
[0028] Figure 4 The flowchart illustrates a method for preventing overflow in a thread pool according to an embodiment of the present disclosure after responding to an instruction that the number of queues in the main thread queue is greater than a first set number of queues.
[0029] Figure 5 The flowchart illustrates a method for preventing overflow in a thread pool according to an embodiment of the present disclosure after responding to an instruction that the number of queues in the thread queue is greater than a second set number of queues.
[0030] Figure 6 This schematically illustrates a flowchart of the thread pool overflow prevention method according to an embodiment of the present disclosure during operation S220;
[0031] Figure 7 The flowchart illustrates a process 500 that further includes the thread pool overflow prevention method according to an embodiment of the present disclosure;
[0032] Figure 8 This schematically illustrates a flowchart of the thread pool overflow prevention method according to an embodiment of the present disclosure during operation S230;
[0033] Figure 9The flowchart schematically illustrates an operation S600 further included in the thread pool overflow prevention method according to an embodiment of the present disclosure;
[0034] Figure 10 This illustration schematically shows a process diagram of a thread pool overflow prevention method according to an embodiment of the present disclosure;
[0035] Figure 11 A block diagram illustrating a thread pool overflow prevention device according to an embodiment of the present disclosure is shown schematically.
[0036] Figure 12 A block diagram of an electronic device for implementing a thread pool overflow prevention method according to an embodiment of the present disclosure is shown schematically. Detailed Implementation
[0037] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0038] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0039] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0040] When using expressions such as "at least one of A, B, or C," it should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (e.g., "a system having at least one of A, B, or C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.). The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, features defined with "first" or "second" may explicitly or implicitly include one or more features.
[0041] In the technical solution disclosed herein, the acquisition, storage, and application of user personal information comply with relevant laws and regulations, necessary confidentiality measures have been taken, and there is no violation of public order and good morals. All operations involving the acquisition, storage, and application of user personal information in the technical solution disclosed herein have been authorized by the user.
[0042] In existing technologies, thread pools all have a core thread, i.e., a maximum thread count limit. When the thread pool reaches this limit, newly submitted tasks are stored in the thread pool's thread queue. Once existing tasks are completed, tasks in the queue are added to the thread pool for processing. If the number of tasks in the queue exceeds the maximum, the current task is discarded, and an exception is thrown, or tasks waiting in the queue are dropped. Therefore, when multiple tasks in the thread pool are abnormal or processing slowly, both the thread pool and the thread queue become full. For newly received tasks, an exception is returned directly. In other words, when multiple abnormal or slow-processing tasks occur in the thread pool, the entire thread pool appears to be filled with abnormal or slow tasks, unable to process other task requests, resulting in a situation where the application server appears to be frozen—a thread pool overflow problem.
[0043] To address the issue of thread pool overflow caused by slow or abnormal transactions easily filling the thread pool, embodiments of this disclosure provide a method, apparatus, electronic device, and storage medium for preventing thread pool overflow. This method can filter out transaction tasks exceeding a set time limit from the thread pool and process tasks with different transaction durations separately, thus preventing thread pool overflow. The thread pool overflow prevention method of this disclosure includes: generating transaction identification information associated with the transaction task based on transaction feature information contained in the transaction request; the transaction identification information is used to determine the transaction duration of transaction tasks in the thread pool; in response to an instruction that the number of queues in the main thread queue is greater than a first set queue number, transferring a first timed-out transaction task from the main thread pool to a slave thread queue; the main thread queue is associated with the main thread pool, and the slave thread queue is associated with the slave thread pool; the transaction duration of the first timed-out transaction task is greater than a first set time limit; in response to an instruction that the number of queues in the slave thread queue is greater than a second set queue number, removing a second timed-out transaction task from the slave thread pool; the transaction duration of the second timed-out transaction task is greater than a second set time limit.
[0044] According to embodiments of this disclosure, transaction timeouts of transaction tasks in the thread pool are determined by generating transaction identification information. First timeout transaction tasks in the main thread pool are transferred to the slave thread queue, and second timeout transaction tasks in the slave thread pool are cleared. This ensures that all transaction tasks in the main thread pool are less than or equal to a first set timeout, and that all transaction tasks in the slave thread pool are less than or equal to a second set timeout. This effectively clears abnormal transaction tasks in both the main and slave thread pools in a timely manner, prevents thread pool overflow, and improves the normal processing capacity and efficiency of the thread pool.
[0045] Figure 1 This illustration schematically depicts an exemplary system architecture where a thread pool overflow prevention method can be applied according to embodiments of this disclosure. It should be noted that... Figure 1 The examples shown are merely examples of system architectures applicable to the embodiments of this disclosure, intended to help those skilled in the art understand the technical content of this disclosure. However, they do not imply that the embodiments of this disclosure cannot be used in other devices, systems, environments, or scenarios. It should be noted that the thread pool overflow prevention method and apparatus provided in the embodiments of this disclosure can be used in the fields of data processing technology and related aspects of data processing in the financial field, and can also be used in any field other than the financial field. The thread pool overflow prevention method and apparatus provided in the embodiments of this disclosure do not limit the application field.
[0046] like Figure 1 As shown, an exemplary system architecture 100 for which thread pool overflow prevention methods can be applied may include terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the terminal devices 101, 102, and 103 and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0047] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as file processing applications, shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0048] Terminal devices 101, 102, and 103 can be various electronic devices with displays that support data analysis, data processing, web browsing, and other functions, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0049] Server 105 can be a server providing various services, such as a backend management server (for example only) that supports data obtained by users using terminal devices 101, 102, and 103 or websites they browse. The backend management server can analyze and process received user requests and other data, and feed back the processing results (such as web pages, information, or data obtained or generated based on user requests) to the terminal devices. It can also analyze or process files sent by users and control the terminal devices based on the processing results, such as restricting access to the terminal devices.
[0050] It should be noted that the thread pool overflow prevention method provided in this disclosure embodiment can generally be executed by server 105. Correspondingly, the thread pool overflow prevention device provided in this disclosure embodiment can generally be located in server 105. The thread pool overflow prevention method provided in this disclosure embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the thread pool overflow prevention device provided in this disclosure embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.
[0051] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0052] Figure 2 A flowchart illustrating a thread pool overflow prevention method according to an embodiment of this disclosure is shown schematically. The garbage file cleanup method of this disclosure embodiment can be applied to the server 105 described above.
[0053] like Figure 2 As shown, the process 200 of the thread pool overflow prevention method of this embodiment includes operations S210 to S230.
[0054] In the embodiments of this disclosure, the thread pool includes a main thread pool and slave thread pools. The main thread pool, for example, has faster processing capabilities and handles normal business operations. The core number of threads in the main thread pool is a set number, which is related to the processing capacity. When the number of threads processing tasks in the main thread pool reaches the set value, no more threads can be added for task processing; the thread pool resources must be released after a thread finishes its task before other tasks can be processed. The slave thread pool has a larger number of threads than the main thread pool. While its processing capacity is weaker than the main thread pool, the slave thread pool can handle slower tasks and, with its larger number of threads, can accommodate more abnormal or slower transactions. This ensures the processing of normal transaction tasks in the main thread pool.
[0055] In operation S210, transaction identification information associated with the transaction task is generated based on the transaction feature information associated with the transaction request of the transaction task. The transaction identification information is used to determine the transaction time of the transaction task in the thread pool.
[0056] In the embodiments of this disclosure, each transaction task has a corresponding transaction request, which is executed and processed in a thread pool and a processing result is returned. The transaction request has associated transaction feature information, which may be obtained, for example, from the transaction data corresponding to the transaction task. The transaction data is input into memory for transaction feature parsing to obtain transaction feature information including transaction name, service name, category name, transaction start time, etc.
[0057] Based on transaction feature information, transaction identification information is generated that is associated with the transaction task. This transaction identification information can be used to identify and obtain various processing data of the transaction task in the thread pool. For example, the transaction time corresponding to the transaction task in the thread pool with the transaction identification information can be determined based on the transaction identification information. The transaction time is the length of time that the transaction task consumes in the thread pool for processing.
[0058] For example, the thread pool includes a main thread pool and a slave thread pool. Determining the transaction time of transaction tasks in the thread pool through transaction identification information includes determining the transaction time of each transaction task in the main thread pool and determining the transaction time of each transaction task in the slave thread pool.
[0059] According to embodiments of this disclosure, the transaction time of transaction tasks in the thread pool is determined by transaction identification information. Tasks with different transaction times in the thread pool can be processed separately, which facilitates the adjustment of the number of tasks in the main thread pool and the slave thread pool, and ensures the running efficiency of the thread pool.
[0060] In operation S220, in response to the instruction that the number of queues in the main thread queue is greater than the first set number of queues, the first timed-out transaction task in the main thread pool is transferred to the slave thread queue. The main thread queue is associated with the main thread pool, and the slave thread queue is associated with the slave thread pool. The transaction time of the first timed-out transaction task is greater than the first set duration.
[0061] In embodiments of this disclosure, the main thread pool has an associated main thread queue, and the slave thread pool has an associated slave thread queue. The main thread queue is used to place pending transaction tasks into the main thread queue for waiting processing when the number of threads in the main thread pool exceeds a maximum value. The slave thread queue is used to place pending transaction tasks into the slave thread queue for waiting processing when the number of threads in the slave thread pool exceeds a maximum value.
[0062] The first setting of the queue number can be, for example, the maximum number of queues in the main thread queue, or a set value, such as half the number of queues in the main thread queue, or other set values.
[0063] The initial timeout can be adjusted based on the actual processing speed of the main thread pool, or based on the actual number or type of transaction tasks, to meet the needs of different transaction tasks.
[0064] When the number of queues in the main thread queue associated with the main thread pool exceeds the first set number of queues, the first timed-out transaction task in the main thread pool is transferred to the slave thread queue. This means that the first timed-out transaction task in the main thread pool is processed asynchronously, thereby ensuring that the transaction time of all transaction tasks in the main thread pool is less than the first set time. This prevents a large number of threads in the main thread pool from being occupied due to transaction tasks with long transaction times.
[0065] In operation S230, in response to an instruction that the number of queues in the slave thread queue is greater than the second set number of queues, the second timed-out transaction task in the slave thread pool is removed from the slave thread pool, and the transaction time of the second timed-out transaction task is greater than the second set duration.
[0066] The second setting for the number of queues can be, for example, the maximum number of queues from the thread queue, or a set value, such as half the number of thread queues, or other settings.
[0067] The second time limit can be adjusted, for example, based on the actual speed at which tasks are processed from the thread pool, or based on the actual number or type of transaction tasks, to meet the needs of different transaction tasks.
[0068] When the number of queues in the slave thread pool associated with the slave thread pool exceeds the second set number of queues, the second timeout transaction task in the slave thread pool will be removed from the slave thread pool to prevent the slave thread pool from overflowing due to the appearance of transaction tasks with longer transaction times.
[0069] The following is combined Figures 3 to 9 The specific process of the thread pool overflow prevention method according to the embodiments of this disclosure will be described in detail.
[0070] Figure 3 The flowchart illustrating the thread pool overflow prevention method according to an embodiment of the present disclosure is shown in operation S210.
[0071] like Figure 3 As shown, operation S210 includes operations S211 to S212.
[0072] In operation S211, transaction feature information associated with the transaction request of the transaction task is obtained.
[0073] In the embodiments of this disclosure, based on the transaction request of the transaction task, the transaction data associated with the transaction request is input into memory for parsing to obtain transaction feature information such as transaction name, service name, category name, and transaction start time. One or more pieces of transaction feature information are obtained.
[0074] In operation S212, the transaction feature information is processed by a hash function to generate transaction identification information associated with the transaction task.
[0075] After acquiring transaction feature information, the transaction features are processed using a preset hash function. For example, the hash function transforms the transaction feature information into a fixed-length output, generating transaction identification information associated with the transaction task. This transaction identification information is unique and can identify different information of the transaction task at different locations.
[0076] For example, the acquired transaction feature information includes the transaction name / service name (e.g., com.xxx.TransXxxServlet). The transaction name / service name is hashed using a hash function to generate transaction identification information. For example, the transaction identification information calculated based on the transaction name com.xxx.TransXxxServlet is aceddesdf1a. Based on this transaction identification information, information related to the transaction task can be obtained from the main thread pool or from the slave thread pool.
[0077] For example, transaction identification information can be used to determine information such as transaction time associated with a transaction task from the main thread pool or from the thread pool.
[0078] According to embodiments of this disclosure, transaction feature information is processed by a hash function, and the generated transaction identification information is unique, preventing duplicates and reducing the probability of errors.
[0079] Figure 4 The flowchart illustrates a thread pool overflow prevention method according to an embodiment of the present disclosure after responding to an instruction that the number of queues in the main thread queue is greater than a first set number of queues.
[0080] like Figure 4 As shown, after responding to the instruction that the number of queues in the main thread queue is greater than the first set number of queues, process 300 is also included. Process 300 includes operations S310 to S320.
[0081] In operation S310, based on the transaction identification information, the transaction time of all transaction tasks in the main thread pool is statistically analyzed to generate the first statistical result.
[0082] In the embodiments of this disclosure, when the number of queues in the main thread queue is greater than the first set number of queues, the transaction time of all transaction tasks in the main thread pool is calculated based on the transaction identification information. That is, the transaction time of the transaction task in the main thread pool from the start of the transaction task to the current time period.
[0083] The first statistical result is the transaction time of all transaction tasks being processed in the main thread pool at the current moment.
[0084] In operation S320, based on the first statistical result and the first set duration, the first timeout transaction task is determined from all transaction tasks in the main thread pool.
[0085] Based on the first statistical result and the first set duration, the transaction time in the first set duration and the transaction time in the first statistical result are compared. If the transaction time of a transaction task is greater than the first set duration, the transaction task in the main thread pool is identified as the first timeout transaction task.
[0086] According to embodiments of this disclosure, by determining the first timed-out transaction task from the main thread pool, it is convenient to process the first timed-out transaction task asynchronously, that is, to transfer the first timed-out transaction task to the slave thread queue, thereby preventing the thread pool from overflowing due to the slow processing of transaction tasks in the main thread pool.
[0087] Figure 5 The flowchart illustrates a method for preventing overflow in a thread pool according to an embodiment of the present disclosure after responding to an instruction that the number of queues in the thread queue is greater than a second set number of queues.
[0088] like Figure 5As shown, after responding to the instruction that the number of queues in the thread queue is greater than the second set number of queues, the process also includes process 400, which includes operations S410 to S420.
[0089] In operation S410, based on the transaction identification information, the transaction time of all transaction tasks from the thread pool is statistically analyzed to generate a second statistical result.
[0090] In operation S420, based on the second statistical result and the second set duration, the second timeout transaction task is determined from all transaction tasks in the thread pool.
[0091] In the embodiments of this disclosure, in order to prevent the thread pool from overflowing due to the excessive processing time of transaction tasks, a second timed-out transaction task is determined from the thread pool according to operations S410 and S420, so as to facilitate the processing of the second timed-out transaction task and prevent the thread pool from overflowing.
[0092] Operations S410 and S420 are similar to those described above as operations S310 and S320, and will not be repeated here. The second set duration is longer than the first set duration, thus ensuring that the slave thread pool can process the first timed-out transaction task in the main thread pool.
[0093] Figure 6 The flowchart illustrating the thread pool overflow prevention method according to an embodiment of the present disclosure is shown in operation S220.
[0094] like Figure 6 As shown, operation S220 includes operations S221 to S222.
[0095] In operation S221, based on the determined first timeout transaction task, the first processing information associated with the first timeout transaction task is obtained from the main thread pool.
[0096] In embodiments of this disclosure, each transaction task processed in the main thread pool has processing information associated with that task, namely, the current processing status and current processing progress of the transaction task. After determining the first timeout transaction task, the first processing information associated with the first timeout transaction task is obtained based on the transaction identification information.
[0097] For example, the first processing information may be process file information generated during the main thread pool's processing of transaction tasks.
[0098] In operation S222, the first timeout transaction task and the first processing information are transferred to the slave thread queue of the slave thread pool.
[0099] In the embodiments of this disclosure, after determining the first timeout transaction task, the first processing information associated with the first timeout transaction task is further determined, and the first timeout transaction task and the first processing information are simultaneously transferred from the main thread pool to the slave thread pool queue of the slave thread pool.
[0100] For example, if the number of threads in the slave thread pool does not reach the maximum value of the slave thread pool, the first timed-out transaction task and the first processing information are input into the slave thread pool for processing. If the number of threads in the slave thread pool reaches the maximum value of the slave thread pool, the first timed-out transaction task waits in the slave thread queue until the task is processed in the slave thread pool. If there is an idle thread, it will continue to execute.
[0101] According to embodiments of this disclosure, by obtaining first processing information and simultaneously transferring the first timed-out transaction task and the first processing information to the slave thread queue of the slave thread pool, the time spent by the slave thread pool in processing tasks can be reduced. That is, processing can continue on the basis of the main thread pool processing the first timed-out transaction task, avoiding reprocessing the transaction task transferred to the slave thread pool from the beginning, effectively saving computing resources and improving processing efficiency.
[0102] Figure 7 The flowchart illustrates a process 500 that further includes the thread pool overflow prevention method according to an embodiment of the present disclosure.
[0103] like Figure 7 As shown, process 500 includes operations S510 to S520.
[0104] In operation S510, based on the determined first timeout transaction task, similar transaction tasks belonging to the same category as the first timeout transaction task are identified from the main thread queue.
[0105] In the embodiments of this disclosure, the first timeout transaction task is determined from the main thread pool. That is, when the transaction task is processed in the main thread pool, the processing time exceeds the first set time. If subsequent tasks of the same type as the transaction task enter the main thread pool again, the problem of the processing time exceeding the first set time will also occur.
[0106] In response, there may also be similar transaction tasks in the main thread queue that belong to the same category as the first timed-out transaction task. Identifying these similar transaction tasks can prevent unnecessary consumption of main thread resources due to timeouts during subsequent processing in the main thread pool.
[0107] For example, the same category could include content such as having the same transaction identification information.
[0108] In the S520 operation, similar transaction tasks are transferred to the slave thread queue.
[0109] In the embodiments of this disclosure, after determining that a transaction task of the same type as the first timeout transaction task belongs to the same category, the transaction task of the same type in the main thread queue is transferred to the slave thread queue, so as to facilitate the processing of the transaction task of the same type in the slave thread pool.
[0110] According to embodiments of this disclosure, by identifying similar transaction tasks and transferring them from the main thread queue to the slave thread queue, unnecessary processes are avoided by having these tasks enter the main thread pool from the main thread queue for processing. By pre-judging the main thread queue, the time spent by the main thread pool in processing similar transaction tasks can be reduced, thus saving main thread pool resources.
[0111] Figure 8 The flowchart illustrating the thread pool overflow prevention method according to an embodiment of the present disclosure is shown in operation S230.
[0112] like Figure 8 As shown, operation S230 includes operations S231 to S232.
[0113] In operation S231, based on the determined second timeout transaction task, second processing information associated with the second timeout transaction task is determined from the thread pool.
[0114] In the embodiments of this disclosure, as described above, the thread pool generates processing information when processing transaction tasks. Processing information is also generated when the slave thread pool is processing tasks. Based on the determined second timeout transaction task, second processing information is determined from the slave thread pool. This facilitates subsequent operations on the second processing information, such as clearing.
[0115] In operation S232, the second timeout transaction task and the second processing information are removed from the slave thread pool.
[0116] In the embodiments of this disclosure, by operating S232, the second timed-out transaction task and the second processing information in the thread pool can be cleared, thereby releasing the thread resources of the thread pool to process other transaction tasks and preventing the thread pool from overflowing due to too many second timed-out transaction tasks.
[0117] Figure 9 The flowchart illustrates an operation S600 that is an additional component of the thread pool overflow prevention method according to an embodiment of the present disclosure.
[0118] like Figure 9 As shown, the overflow prevention method in this embodiment of the present disclosure further includes operation S600, in which transaction tasks from the thread pool are periodically polled and transaction tasks whose transaction time is greater than a third set time are cleared.
[0119] In the embodiments of this disclosure, when the number of threads in the thread pool does not meet the maximum value, and there are some tasks in the thread pool with very long transaction times, it indicates that these tasks may be abnormal and unable to return processing results. To address this, the transaction tasks in the thread pool are periodically polled to count their transaction times, and transactions with transaction times exceeding a third set timeout are cleared. For example, transactions with transaction times exceeding the third set timeout can be third timeout transaction tasks.
[0120] For example, the third set duration can be a duration that can be adjusted according to actual needs.
[0121] According to embodiments of this disclosure, by periodically polling the transaction tasks in the slave thread pool, abnormal transaction tasks are filtered out, thus preventing such transaction tasks from occupying thread pool resources and minimizing the impact of abnormal transactions on slave thread pool resources.
[0122] In the embodiments of this disclosure, after a transaction task is transferred or cleared, the thread pool resources are returned to facilitate the processing of other transaction tasks.
[0123] Figure 10 The schematic diagram illustrates a method for preventing thread pool overflow according to an embodiment of the present disclosure.
[0124] like Figure 10 As shown, the process 700 of the thread pool overflow prevention method in this embodiment of the present disclosure is as follows.
[0125] First, a transaction request 701 is received. Based on the transaction feature information associated with the transaction request 701, transaction identification information 702 is generated. This transaction identification information is used to determine the transaction time of the transaction tasks in the main thread pool 704 and the slave thread pool 708. The main thread pool 704 has an associated main thread queue 703, and the slave thread pool 708 has an associated slave thread queue 707.
[0126] Next, step 705: Determine if the number of queues in the main thread queue is greater than the first set queue number. If yes, then determine the first timed-out transaction task 706 from the main thread pool. The transaction time of the first timed-out transaction task 706 is greater than the first set timeout, and the determined first timed-out transaction task 706 and the first processing information associated with the first timed-out transaction task are transferred to the slave thread queue 707. If not, the main thread pool processes the transaction task, proceeds to transaction task processing completion 709, and returns the processing result 712.
[0127] After the transaction task is processed in the main thread pool 704, the processing result 712 is returned.
[0128] In thread pool queue 707, step 710: Determine if the number of queues in the thread pool is greater than the second set queue number. If yes, then determine the second timeout transaction task 711 from thread pool 708. The transaction time of the second timeout transaction task 711 is greater than the second set duration, and clear the second timeout transaction task 711 and the second processing information associated with the second timeout transaction task. If not, return the processing result 712.
[0129] After the transaction task is processed from thread pool 708, the processing result 712 is returned.
[0130] In addition, the thread pool 708 is periodically polled 713 to identify the third timeout transaction task 714 from the thread pool 708 whose transaction time exceeds the third set time. The third timeout transaction task 714 is then cleared, and the resources of the thread pool are returned to process other transaction tasks.
[0131] According to embodiments of this disclosure, transaction timeouts of transaction tasks in the thread pool are determined by generating transaction identification information. First timeout transaction tasks in the main thread pool are transferred to the slave thread queue, and second timeout transaction tasks in the slave thread pool are cleared. This ensures that all transaction tasks in the main thread pool are less than or equal to a first set timeout, and that all transaction tasks in the slave thread pool are less than or equal to a second set timeout. This effectively clears abnormal transaction tasks in both the main and slave thread pools in a timely manner, prevents thread pool overflow, and improves the normal processing capacity and efficiency of the thread pool.
[0132] Figure 11 A block diagram of a thread pool overflow prevention device according to an embodiment of the present disclosure is shown schematically.
[0133] like Figure 11 As shown, the thread pool overflow prevention device 800 includes a generation module 801, a first response module 802, and a second response module 803.
[0134] The generation module 801 is configured to generate transaction identification information associated with a transaction task based on the transaction feature information associated with the transaction request of the transaction task. The transaction identification information is used to determine the transaction time of the transaction task in the thread pool. In one embodiment, the generation module 801 can be used to perform the operation S210 described above, which will not be repeated here.
[0135] The first response module 802 is configured to respond to an instruction that the number of queues in the main thread queue is greater than a first set number of queues, by transferring the first timed-out transaction task in the main thread pool to the slave thread queue. The main thread queue is associated with the main thread pool, and the slave thread queue is associated with the slave thread pool. The transaction time of the first timed-out transaction task is greater than a first set duration. In one embodiment, the first response module 802 can be used to execute the operation S220 described above, which will not be repeated here.
[0136] The second response module 803 is configured to, in response to an instruction that the number of queues in the slave thread queue exceeds a second set number of queues, remove the second timed-out transaction task from the slave thread pool, where the transaction time of the second timed-out transaction task exceeds a second set duration. In one embodiment, the second response module 803 can be used to execute the operation S230 described above, which will not be repeated here.
[0137] In some exemplary embodiments of this disclosure, the generation module includes a generation unit configured to: acquire transaction feature information associated with a transaction request of a transaction task; and process the transaction feature information through a hash function to generate transaction identification information associated with the transaction task.
[0138] In some exemplary embodiments of this disclosure, the thread pool overflow prevention device 800 further includes a first statistics module, which is configured to: after responding to an instruction that the number of queues in the main thread queue is greater than a first set number of queues, perform statistics on the transaction time of all transaction tasks in the main thread pool based on transaction identification information, and generate a first statistical result; and determine a first timeout transaction task from all transaction tasks in the main thread pool based on the first statistical result and a first set duration.
[0139] In some exemplary embodiments of this disclosure, the thread pool overflow prevention device 800 further includes a second statistics module, which is configured to: after responding to an instruction that the number of queues in the slave thread queue is greater than a second set number of queues, perform statistics on the transaction time of all transaction tasks in the slave thread pool based on transaction identification information, and generate a second statistical result; and determine a second timeout transaction task from all transaction tasks in the slave thread pool based on the second statistical result and a second set duration.
[0140] In some exemplary embodiments of this disclosure, the first response module further includes a first response unit, which is configured to: obtain first processing information associated with the first timeout transaction task in the main thread pool according to the determined first timeout transaction task; and transfer the first timeout transaction task and the first processing information to the slave thread queue of the slave thread pool.
[0141] In some exemplary embodiments of this disclosure, the thread pool overflow prevention device 800 further includes a determining module, which is configured to: determine, based on the determined first timeout transaction task, identify similar transaction tasks belonging to the same category as the first timeout transaction task from the main thread queue; and transfer similar transaction tasks to the slave thread queue.
[0142] In some exemplary embodiments of this disclosure, the second response module further includes a second response unit, which is configured to: determine second processing information associated with the determined second timeout transaction task from the slave thread pool according to the determined second timeout transaction task; and clear the second timeout transaction task and the second processing information from the slave thread pool.
[0143] In some exemplary embodiments of this disclosure, the thread pool overflow prevention device 800 further includes a timed polling module, which is configured to: periodically poll the transaction tasks from the thread pool and clear the transaction tasks whose transaction time is greater than a third set time.
[0144] According to embodiments of this disclosure, any plurality of modules among generation module 801, first response module 802, and second response module 803 can be merged into one module, or any one of these modules can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of generation module 801, first response module 802, and second response module 803 can be at least partially implemented as hardware circuitry, such as field-programmable gate array (FPGA), programmable logic array (PLA), system-on-a-chip, system-on-a-substrate, system-on-package, application-specific integrated circuit (ASIC), or implemented by any other reasonable means of integrating or packaging circuitry, or implemented in any one of software, hardware, and firmware methods, or in a suitable combination of any of these. Alternatively, at least one of generation module 801, first response module 802, and second response module 803 can be at least partially implemented as a computer program module, which, when run, can perform corresponding functions.
[0145] Figure 12 A block diagram of an electronic device for implementing a thread pool overflow prevention method according to an embodiment of the present disclosure is shown schematically. Figure 12 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0146] like Figure 12As shown, an electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0147] RAM 903 stores various programs and data required for the operation of electronic device 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 902 and / or RAM 903. It should be noted that the programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0148] According to embodiments of this disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to a bus 904. The electronic device 900 may also include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.
[0149] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the thread pool overflow prevention method according to the embodiments of this disclosure.
[0150] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 902 and / or RAM 903 and / or one or more memories other than ROM 902 and RAM 903 described above.
[0151] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code enables the computer system to implement the thread pool overflow prevention method provided in embodiments of this disclosure.
[0152] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0153] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0154] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0155] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on a user's computing device, partially on a user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0156] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0157] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0158] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. A method for preventing overflow in a thread pool, wherein the thread pool includes a main thread pool and slave thread pools, the method comprising: Based on the transaction feature information associated with the transaction request of the transaction task, transaction identification information associated with the transaction task is generated, and the transaction identification information is used to determine the transaction time of the transaction task in the thread pool. In response to an instruction that the number of queues in the main thread queue is greater than the first set number of queues, the first timed-out transaction task in the main thread pool is transferred to the slave thread queue. The main thread queue is associated with the main thread pool, and the slave thread queue is associated with the slave thread pool. The transaction time of the first timed-out transaction task is greater than the first set duration. In response to an instruction that the number of queues in the slave thread queue is greater than the second set number of queues, the second timed-out transaction task in the slave thread pool is removed from the slave thread pool, and the transaction time of the second timed-out transaction task is greater than the second set duration.
2. The method according to claim 1, wherein, The step of generating transaction identification information associated with the transaction task based on the transaction feature information associated with the transaction request of the transaction task includes: Obtain the transaction feature information associated with the transaction request of the transaction task; and The transaction feature information is processed by a hash function to generate transaction identification information associated with the transaction task.
3. The method according to claim 1, wherein, Also includes: After responding to an instruction that the number of queues in the main thread queue exceeds the first set number of queues, Based on the transaction identification information, the transaction time of all transaction tasks in the main thread pool is statistically analyzed to generate a first statistical result; Based on the first statistical results and the first set duration, the first timeout transaction task is determined from all transaction tasks in the main thread pool.
4. The method according to claim 1, wherein, Also includes: After responding to the instruction that the number of queues in the slave thread queue is greater than the second set number of queues, Based on the transaction identification information, the transaction time of all transaction tasks in the thread pool is statistically analyzed to generate a second statistical result; Based on the second statistical results and the second set duration, a second timeout transaction task is determined from all transaction tasks in the thread pool.
5. The method according to claim 1, wherein, The step of transferring the first timed-out transaction task in the main thread pool to the slave thread queue includes: Based on the determined first timeout transaction task, obtain the first processing information associated with the first timeout transaction task from the main thread pool; and The first timed-out transaction task and the first processing information are transferred to the slave thread queue of the slave thread pool.
6. The method according to claim 5, wherein, Also includes: Based on the determined first timeout transaction task, identify similar transaction tasks belonging to the same category as the first timeout transaction task from the main thread queue; The same type of transaction task is transferred to the slave thread queue.
7. The method according to claim 4, wherein, The step of removing the second timed-out transaction task from the thread pool includes: Based on the determined second timeout transaction task, second processing information associated with the second timeout transaction task is determined from the thread pool; The second timeout transaction task and the second processing information are removed from the thread pool.
8. The method according to claim 1, wherein, Also includes: The transaction tasks from the thread pool are periodically polled, and transaction tasks whose transaction time exceeds a third set time are cleared.
9. A device for preventing overflow in a thread pool, the thread pool comprising a main thread pool and a slave thread pool, the device comprising: The generation module is configured to generate transaction identification information associated with the transaction task based on the transaction feature information associated with the transaction request of the transaction task. The transaction identification information is used to determine the transaction time of the transaction task in the thread pool. The first response module is configured to respond to an instruction that the number of queues in the main thread queue is greater than a first set number of queues, and to transfer the first timed-out transaction task in the main thread pool to the slave thread queue. The main thread queue is associated with the main thread pool, the slave thread queue is associated with the slave thread pool, and the transaction time of the first timed-out transaction task is greater than a first set duration. The second response module is configured to, in response to an instruction that the number of queues in the slave thread queue is greater than a second set number of queues, remove the second timed-out transaction task from the slave thread pool, wherein the transaction time of the second timed-out transaction task is greater than a second set duration.
10. An electronic device, comprising: One or more processors; A storage device for storing executable instructions, which, when executed by the processor, implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, implement the method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Electronic device and task processing method executed by electronic device
CN110333942A
Resource allocation method and device, computer equipment and storage medium
CN112783659A