CN116991575A - Thread pool management method and device, medium and equipment - Google Patents

Thread pool management method and device, medium and equipment Download PDF

Info

Publication number
CN116991575A
CN116991575A CN202310538098.5A CN202310538098A CN116991575A CN 116991575 A CN116991575 A CN 116991575A CN 202310538098 A CN202310538098 A CN 202310538098A CN 116991575 A CN116991575 A CN 116991575A
Authority
CN
China
Prior art keywords
thread
state
list
waiting
threads
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310538098.5A
Other languages
Chinese (zh)
Inventor
齐震宇
陈善君
侯俊栋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Yunxi Technology Co ltd
Original Assignee
Shanghai Yunxi Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Yunxi Technology Co ltd filed Critical Shanghai Yunxi Technology Co ltd
Priority to CN202310538098.5A priority Critical patent/CN116991575A/en
Publication of CN116991575A publication Critical patent/CN116991575A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Abstract

The invention provides a thread pool management method and device, a medium and equipment. The method comprises the following steps: for each process, creating a first number of threads for a thread pool, allocating a corresponding ID for each thread, and configuring a corresponding waiting thread list for the thread pool; the waiting thread list stores the ID of the thread in the idle state currently; when a thread call request is received, judging whether the waiting thread list is empty or not; if not, selecting an ID from the waiting thread list, removing the ID from the waiting thread list, and executing corresponding operation by using a thread corresponding to the ID; and after any one thread in the thread pool finishes corresponding operation, placing the ID corresponding to the thread in the waiting thread list. The embodiment of the invention can realize repeated calling of the threads and reduce resource consumption.

Description

Thread pool management method and device, medium and equipment
Technical Field
The present invention relates to the technical field of thread pools, and in particular, to a thread pool management method and apparatus, a medium, and a device.
Background
With the development of hardware and software technology and the increasing demand of complex business, the trend of concurrent programming is promoted, and the program can bring the hardware performance into play extremely through the concurrent programming, and meanwhile, the processing speed of tasks is greatly improved. To meet this demand, the concept of thread pools may be introduced. How to implement thread pool management is a matter of current concern.
Disclosure of Invention
Aiming at least one technical problem, the embodiment of the invention provides a thread pool management method, a thread pool management device, a thread pool management medium and thread pool management equipment.
According to a first aspect, a thread pool management method provided by an embodiment of the present invention includes:
for each process, creating a first number of threads for a thread pool, allocating a corresponding ID for each thread, and configuring a corresponding waiting thread list for the thread pool; the waiting thread list stores the ID of the thread in the idle state currently;
when a thread call request is received, judging whether the waiting thread list is empty or not;
if not, selecting an ID from the waiting thread list, removing the ID from the waiting thread list, and executing corresponding operation by using a thread corresponding to the ID;
and after any one thread in the thread pool finishes corresponding operation, placing the ID corresponding to the thread in the waiting thread list.
According to a second aspect, a thread pool management device provided by an embodiment of the present invention includes:
the thread creation module is used for creating a first number of threads for each process, distributing corresponding IDs for each thread, and configuring a corresponding waiting thread list for the thread pool; the waiting thread list stores the ID of the thread in the idle state currently;
the first judging module is used for judging whether the waiting thread list is empty or not when a thread calling request is received;
the ID removing module is used for selecting an ID from the waiting thread list if the ID is not empty, removing the ID from the waiting thread list, and executing corresponding operation by utilizing a thread corresponding to the ID;
and the ID recovery module is used for placing the ID corresponding to the thread in the waiting thread list after any one thread in the thread pool finishes the corresponding operation.
According to a third aspect, embodiments of the present invention provide a computer-readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method provided by the first aspect.
According to a fourth aspect, a computing device provided by an embodiment of the present invention includes a memory and a processor, where the memory stores executable code, and the processor implements the method provided by the first aspect when executing the executable code.
The thread pool management method, the thread pool management device, the thread pool management medium and the thread pool management equipment provided by the embodiment of the invention are used for checking whether a waiting thread list is empty or not when a thread call request is received, namely checking whether an available thread exists in a thread pool or not. If there are threads available, a thread is selected for use and the thread's ID is removed from the waiting thread list. And after any one thread in the thread pool finishes corresponding operation, placing the ID corresponding to the thread in the waiting thread list. In this way, repeated calls of threads may be implemented. By reusing the already created threads, the consumption caused by repeated creation and destruction of threads, i.e. the resource consumption, can be reduced. And the response speed can be improved because the task can be immediately executed without re-creating the thread when it arrives. And the manageability of the threads can be improved by waiting for the thread list, so that the thread pool can allocate available threads for the task.
Drawings
FIG. 1 is a flow chart illustrating a thread pool management method according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a thread pool management method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram illustrating a transition from thread pool state in accordance with one embodiment of the present invention.
Detailed Description
In a first aspect, an embodiment of the present invention provides a thread pool management method, referring to fig. 1 and fig. 2, the method may include steps S110 to S140 as follows:
s110, establishing a first number of threads for each process, distributing corresponding IDs for each thread, and configuring a corresponding waiting thread list for the thread pool; the waiting thread list stores the ID of the thread in the idle state currently;
the step S110 is an initialization phase of the thread pool, in which a first number of threads are created, each thread having a corresponding ID for uniquely identifying the thread. And a waiting thread list is set, the IDs of the threads in the idle state are stored in the waiting thread list, and the IDs of the threads just created are all located in the waiting thread list when the threads just start. With a call to a thread in the thread pool, the ID of the called thread is removed from the waiting thread list, so that the waiting thread list only stores the IDs of threads that are currently in an idle state.
S120, judging whether the waiting thread list is empty or not when a thread calling request is received;
that is, when a thread call request sent from a requester is received, it is first determined whether the waiting thread list is empty. If empty, it indicates that none of the first number of threads in the thread pool are in an idle state, and no threads are currently available to the requestor. If not empty, it is indicated that there is a thread in the thread pool that is in an idle state, which may be assigned to the requesting party for use.
S130, if not, selecting an ID from the waiting thread list, removing the ID from the waiting thread list, and executing corresponding operation by using a thread corresponding to the ID;
that is, if the waiting thread list is not empty, an ID is selected from the waiting thread list, the ID is removed from the waiting thread list, and then a thread corresponding to the ID is utilized to perform a corresponding operation according to a thread call request of a requester. That is, the thread of the ID is assigned to the requestor for use.
And S140, after any one thread in the thread pool finishes corresponding operation, placing the ID corresponding to the thread in the waiting thread list.
That is, after any one thread has completed the corresponding operation, the idle state is restored, and thus the ID of that thread is replaced in the waiting thread list, waiting to be called again.
It can be seen that in this way repeated calls of threads can be achieved. By reusing the already created threads, the consumption caused by repeated creation and destruction of threads, i.e. the resource consumption, can be reduced. And the response speed can be improved because the task can be immediately executed without re-creating the thread when it arrives. And the manageability of the threads can be improved by waiting for the thread list, so that the thread pool can allocate available threads for the task.
It will be appreciated that the thread pool corresponds to a dynamic array in which the number of threads has an upper limit, which of course is dynamic and can vary.
In one embodiment, the method provided by the embodiment of the invention can further include:
if the waiting thread list is empty, judging whether the number of threads in the thread pool reaches the upper limit number; if the number of threads does not reach the upper limit, a second number of threads are re-created for the thread pool, one thread is selected from the re-created second number of threads to execute corresponding operation, and IDs of all other threads except the selected thread in the re-created second number of threads are placed in the waiting thread list; wherein the sum of the first number and the second number is equal to or less than the upper limit number.
That is, if the waiting thread list is found to be empty by the judgment, it is necessary to judge whether the number of threads in the thread pool reaches the upper limit number at this time. If the upper number is not reached, then creation of new threads in the thread pool may continue, i.e., some threads may be reinitialized. After creating a new thread, selecting a thread from the newly created threads for the requester to call, i.e. executing corresponding operation by using the selected thread. The other threads newly created are in an idle state, so that the IDs of the other threads except the selected thread in the newly created threads are placed in a waiting thread list to wait for being called.
In one embodiment, the method provided by the embodiment of the invention can further include:
if the number of threads in the thread pool reaches the upper limit number, creating temporary threads, setting a temporary thread list, and placing the ID of the temporary threads in the temporary thread list;
executing corresponding operation by utilizing the temporary thread;
and after the temporary thread finishes the corresponding operation, recycling the temporary thread, and removing the ID of the temporary thread from the temporary thread list.
That is, if it is judged that the number of threads in the thread pool reaches the upper limit number, a temporary thread may be created, a temporary thread list may be set, and the ID of the temporary thread may be placed in the temporary thread list. And then, carrying out corresponding operation by utilizing the temporary thread according to the thread call request of the requester, recovering the temporary thread after the operation is finished, and removing the ID of the temporary thread from the temporary thread list, so that the temporary thread disappears in the thread pool, the endless increase of threads in the thread pool can be avoided, and the nonsensical waste of resources caused by excessive spare threads can be avoided. At the same time, the problem of memory overflow caused by creating too many threads is avoided.
In one embodiment, the method provided by the embodiment of the invention can further include:
when a process is safely ended, marking the thread pool corresponding to the process as a stop state, calling a stop method for each thread in the thread pool so as to stop each thread from executing operation, and recovering each thread in the thread pool; and closing the thread pool.
It will be appreciated that when a process is safely terminated, the interface that invokes the thread pool to which the process corresponds will be closed. And marking the state of the thread pool corresponding to the process as a stop state, and then calling a stop method for each thread in the thread pool, so that each thread finishes executing tasks, and further recovering each thread to safely close the thread pool.
It is appreciated that a user may first check if a thread pool is closed while using thread resources. And if the resource application is closed, stopping the current resource application. If the thread pool is not closed, it is checked whether the waiting thread list is empty, i.e. whether there are threads available in the thread pool. If there are threads available, one thread is selected for use. If there are no threads available, a determination is made as to whether the number of threads in the thread pool reaches an upper limit number. If the upper limit number is reached, a temporary thread is applied. If the upper number is not reached, then the creation of new threads continues.
In one embodiment, the method provided by the embodiment of the invention can further include:
setting a corresponding class for each thread; the class corresponding to each thread comprises basic information of the thread, and the basic information comprises an ID and a thread state.
In addition to the ID and the thread state, the class may also have contents such as the state of executing the task and the type of the thread, so as to monitor the thread state and manage the basic information.
In one embodiment, the thread state is one of an initialization state, a wait state, a run state, and an error state; the initialization state is a state in the process of thread creation, the waiting state is a state when the thread is not called after the thread is created successfully, the running state is a state in the process that the thread is called and corresponding operation is executed, and the error state is a state when the thread is created failed.
That is, one thread includes 4 states throughout the lifecycle. The threads are in an initialized state during the initialization of the thread pool. When the thread is created successfully and has not been invoked yet, it is in a waiting state. If the thread creation fails, it is in an error state. The thread in the waiting state may be called to provide a service to the outside. The thread is in a running state in the process of being called to execute the task, and returns to a waiting state after the task execution is finished.
Regardless of whether the thread is in a waiting state or an operating state, after the user closes the thread pool, the thread executing the loop task also transitions from the operating state back to the waiting state and destroys the corresponding resource.
In one embodiment, the method provided by the embodiment of the invention can further include:
configuring a corresponding state for the thread pool, and managing the life cycle of the thread pool according to the state of the thread pool;
wherein the thread pool is in an initial state when a first number of threads have not been created; creating a first number of threads in the thread pool, wherein the state of the thread pool is an operation state; when the waiting thread list is empty, the thread pool enters a busy state; and when the corresponding process is safely ended, the thread pool enters a stop state.
It can be seen that the state of the thread pool also includes 4 types: an initial state, an operating state, a busy state, a stopped state. Referring to fig. 3, the thread pool is originally in an initial state, i.e., init state, and cannot provide services to the outside. After the first number of threads are created, the thread pool is in a running state, and services can be provided for the outside. The threads in the thread pool are gradually occupied in the process of providing service to the outside, and idle threads are fewer and fewer, and when a waiting thread list of the thread pool is empty, the fact that the threads in the thread pool are temporarily unavailable is indicated. At this time, a new thread needs to be created or a temporary thread needs to be applied, and at this time, the thread pool is briefly in a BUSY state, namely, a BUSY state.
Whether the thread pool is in a running state or a busy state, when a stopping method of the thread pool is called, the thread pool is required to exit safely, the thread pool stops providing services to the outside, and after the operation in the process of executing the thread waits for synchronous completion, the state of the thread pool is transferred to a stopping state, namely a stop state.
It will be appreciated that the pooling concept is referenced, and that a first number of threads are created and saved during an initialization phase, and thread resources are uniformly managed for other users to acquire and use.
It is appreciated that a thread pool is a tool for managing threads that maintains multiple threads, which reduces resource consumption and improves system performance. Thread pools are a pooling technique, and similarly database connection pools, HTTP connection pools, and the like. The idea of pooling is mainly to reduce the consumption of resources obtained and ended each time and improve the utilization rate of the resources.
It can be understood that by the thread pool management method, the use efficiency of system resources can be improved in a service process concurrency scene, and the problem of consumption of the system resources by threads in frequent creation and destruction is relieved. Therefore, in the concurrency scene, the thread used in the embodiment of the invention provides a management scheme which has high stability, high concurrency processing capacity and high performance and can perform unified management and monitoring on the threads in a pooling design idea.
In a second aspect, an embodiment of the present invention provides a thread pool management apparatus, including:
the thread creation module is used for creating a first number of threads for each process, distributing corresponding IDs for each thread, and configuring a corresponding waiting thread list for the thread pool; the waiting thread list stores the ID of the thread in the idle state currently;
the first judging module is used for judging whether the waiting thread list is empty or not when a thread calling request is received;
the ID removing module is used for selecting an ID from the waiting thread list if the ID is not empty, removing the ID from the waiting thread list, and executing corresponding operation by utilizing a thread corresponding to the ID;
and the ID recovery module is used for placing the ID corresponding to the thread in the waiting thread list after any one thread in the thread pool finishes the corresponding operation.
In one embodiment, the apparatus provided by the embodiment of the present invention may further include:
the second judging module is used for judging whether the number of threads in the thread pool reaches the upper limit number if the waiting thread list is empty;
the first processing module is used for recreating a second number of threads for the thread pool if the upper limit number is not reached, selecting one thread from the recreated second number of threads to execute corresponding operation, and placing IDs of all other threads except the selected thread in the recreated second number of threads in the waiting thread list; wherein the sum of the first number and the second number is equal to or less than the upper limit number.
In one embodiment, the apparatus may further include:
the second processing module is used for creating temporary threads, setting a temporary thread list and placing the ID of the temporary threads in the temporary thread list if the number of threads in the thread pool reaches the upper limit number; executing corresponding operation by utilizing the temporary thread; and after the temporary thread finishes the corresponding operation, recycling the temporary thread, and removing the ID of the temporary thread from the temporary thread list.
In one embodiment, the apparatus further comprises:
the thread pool closing module is used for marking the thread pool corresponding to a process as a stop state when the process is safely ended, calling a stop method for each thread in the thread pool so as to stop each thread from executing operation, and recovering each thread in the thread pool; and closing the thread pool.
In one embodiment, the apparatus further comprises:
the first management module is used for setting a corresponding class for each thread; the class corresponding to each thread comprises basic information of the thread, and the basic information comprises an ID and a thread state.
In one embodiment, the thread state is one of an initialization state, a wait state, a run state, and an error state; the initialization state is a state in the process of thread creation, the waiting state is a state when the thread is not called after the thread is created successfully, the running state is a state in the process that the thread is called and corresponding operation is executed, and the error state is a state when the thread is created failed.
In one embodiment, the apparatus further comprises:
the second management module is used for configuring a corresponding state for the thread pool, and managing the life cycle of the thread pool according to the state of the thread pool; wherein the thread pool is in an initial state when a first number of threads have not been created; creating a first number of threads in the thread pool, wherein the state of the thread pool is an operation state; when the waiting thread list is empty, the thread pool enters a busy state; and when the corresponding process is safely ended, the thread pool enters a stop state.
It may be understood that, for explanation, specific implementation, beneficial effects, examples, etc. of the content in the apparatus provided by the embodiment of the present invention, reference may be made to corresponding parts in the method provided in the first aspect, which are not repeated herein.
In a third aspect, embodiments of the present invention provide a computer readable medium having stored thereon computer instructions which, when executed by a processor, cause the processor to perform the method provided in the first aspect.
Specifically, a system or apparatus provided with a storage medium on which a software program code realizing the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or apparatus may be caused to read out and execute the program code stored in the storage medium.
In this case, the program code itself read from the storage medium may realize the functions of any of the above-described embodiments, and thus the program code and the storage medium storing the program code form part of the present invention.
Examples of the storage medium for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (e.g., CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a nonvolatile memory card, and a ROM. Alternatively, the program code may be downloaded from a server computer by a communication network.
Further, it should be apparent that the functions of any of the above-described embodiments may be implemented not only by executing the program code read out by the computer, but also by causing an operating system or the like operating on the computer to perform part or all of the actual operations based on the instructions of the program code.
Further, it is understood that the program code read out by the storage medium is written into a memory provided in an expansion board inserted into a computer or into a memory provided in an expansion module connected to the computer, and then a CPU or the like mounted on the expansion board or the expansion module is caused to perform part and all of actual operations based on instructions of the program code, thereby realizing the functions of any of the above embodiments.
It may be appreciated that, for explanation, specific implementation, beneficial effects, examples, etc. of the content in the computer readable medium provided by the embodiment of the present invention, reference may be made to corresponding parts in the method provided in the first aspect, and details are not repeated herein.
In a fourth aspect, one embodiment of the present specification provides a computing device comprising a memory having executable code stored therein and a processor that, when executing the executable code, performs the method of any one of the embodiments of the specification.
It may be appreciated that, for explanation, specific implementation, beneficial effects, examples, etc. of the content in the computing device provided by the embodiment of the present invention, reference may be made to corresponding parts in the method provided in the first aspect, which are not repeated herein.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments in part.
Those skilled in the art will appreciate that in one or more of the examples described above, the functions described in the present invention may be implemented in hardware, software, a pendant, or any combination thereof. When implemented in software, these functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium.
The foregoing embodiments have been provided for the purpose of illustrating the general principles of the present invention in further detail, and are not to be construed as limiting the scope of the invention, but are merely intended to cover any modifications, equivalents, improvements, etc. based on the teachings of the invention.

Claims (10)

1. A method of thread pool management, comprising:
for each process, creating a first number of threads for a thread pool, allocating a corresponding ID for each thread, and configuring a corresponding waiting thread list for the thread pool; the waiting thread list stores the ID of the thread in the idle state currently;
when a thread call request is received, judging whether the waiting thread list is empty or not;
if not, selecting an ID from the waiting thread list, removing the ID from the waiting thread list, and executing corresponding operation by using a thread corresponding to the ID;
and after any one thread in the thread pool finishes corresponding operation, placing the ID corresponding to the thread in the waiting thread list.
2. The method as recited in claim 1, further comprising:
if the waiting thread list is empty, judging whether the number of threads in the thread pool reaches the upper limit number;
if the number of threads does not reach the upper limit, a second number of threads are re-created for the thread pool, one thread is selected from the re-created second number of threads to execute corresponding operation, and IDs of all other threads except the selected thread in the re-created second number of threads are placed in the waiting thread list; wherein the sum of the first number and the second number is equal to or less than the upper limit number.
3. The method as recited in claim 2, further comprising:
if the number of threads in the thread pool reaches the upper limit number, creating temporary threads, setting a temporary thread list, and placing the ID of the temporary threads in the temporary thread list;
executing corresponding operation by utilizing the temporary thread;
and after the temporary thread finishes the corresponding operation, recycling the temporary thread, and removing the ID of the temporary thread from the temporary thread list.
4. The method as recited in claim 1, further comprising:
when a process is safely ended, marking the thread pool corresponding to the process as a stop state, calling a stop method for each thread in the thread pool so as to stop each thread from executing operation, and recovering each thread in the thread pool; and closing the thread pool.
5. The method as recited in claim 1, further comprising:
setting a corresponding class for each thread; the class corresponding to each thread comprises basic information of the thread, and the basic information comprises an ID and a thread state.
6. The method of claim 5, wherein the thread state is one of an initialization state, a wait state, a run state, and an error state; the initialization state is a state in the process of thread creation, the waiting state is a state when the thread is not called after the thread is created successfully, the running state is a state in the process that the thread is called and corresponding operation is executed, and the error state is a state when the thread is created failed.
7. The method as recited in claim 1, further comprising:
configuring a corresponding state for the thread pool, and managing the life cycle of the thread pool according to the state of the thread pool;
wherein the thread pool is in an initial state when a first number of threads have not been created; creating a first number of threads in the thread pool, wherein the state of the thread pool is an operation state; when the waiting thread list is empty, the thread pool enters a busy state; and when the corresponding process is safely ended, the thread pool enters a stop state.
8. A thread pool management apparatus, comprising:
the thread creation module is used for creating a first number of threads for each process, distributing corresponding IDs for each thread, and configuring a corresponding waiting thread list for the thread pool; the waiting thread list stores the ID of the thread in the idle state currently;
the first judging module is used for judging whether the waiting thread list is empty or not when a thread calling request is received;
the ID removing module is used for selecting an ID from the waiting thread list if the ID is not empty, removing the ID from the waiting thread list, and executing corresponding operation by utilizing a thread corresponding to the ID;
and the ID recovery module is used for placing the ID corresponding to the thread in the waiting thread list after any one thread in the thread pool finishes the corresponding operation.
9. A computer readable storage medium, having stored thereon a computer program which, when executed in a computer, causes the computer to perform a method implementing any of claims 1 to 7.
10. A computing device comprising a memory and a processor, the memory having executable code stored therein, the processor, when executing the executable code, implementing the method of any one of claims 1-7.
CN202310538098.5A 2023-05-12 2023-05-12 Thread pool management method and device, medium and equipment Pending CN116991575A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310538098.5A CN116991575A (en) 2023-05-12 2023-05-12 Thread pool management method and device, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310538098.5A CN116991575A (en) 2023-05-12 2023-05-12 Thread pool management method and device, medium and equipment

Publications (1)

Publication Number Publication Date
CN116991575A true CN116991575A (en) 2023-11-03

Family

ID=88532836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310538098.5A Pending CN116991575A (en) 2023-05-12 2023-05-12 Thread pool management method and device, medium and equipment

Country Status (1)

Country Link
CN (1) CN116991575A (en)

Similar Documents

Publication Publication Date Title
US7349970B2 (en) Workload management of stateful program entities
US7406699B2 (en) Enhanced runtime hosting
US8789043B2 (en) Optimized placement planning for virtual machines in a network by breaking relocation graph into one or more cores to apply different solutions
US7089550B2 (en) Method and system for performing SW upgrade in a real-time system
CN111641515B (en) VNF life cycle management method and device
US20090024653A1 (en) Dynamic configuration and self-tuning of inter-nodal communication resources in a database management system
CN111367659B (en) Resource management method, equipment and medium for nodes in Kubernetes
CN104461744A (en) Resource allocation method and device
EP1366411A2 (en) Local transaction management
CN110597614B (en) Resource adjustment method and device
CN109614167B (en) Method and system for managing plug-ins
CN102063338A (en) Method and device for requesting exclusive resource
JPWO2012008016A1 (en) Multithread processing apparatus, multithread processing system, multithread processing program, and multithread processing method
CN109347716B (en) Instantiation method and device of consumer VNF
CN116991575A (en) Thread pool management method and device, medium and equipment
WO2015184902A1 (en) Concurrent processing method for intelligent split-screen and corresponding intelligent terminal
CN115114022A (en) Method, system, device and medium for using GPU resources
CN112698914B (en) Workflow task container generation system and method
CN115220908A (en) Resource scheduling method, device, electronic equipment and storage medium
CN111580938B (en) Transaction processing method, device, equipment and medium for work unit
CN113641641A (en) Switching method, switching system, equipment and storage medium of file storage service
CN114691309A (en) Batch business processing system, method and device
CN106027616A (en) Connection pool implementing method and system of PaaS (Platform As A Service) platform
CN111782363A (en) Method and flow system for supporting multi-service scene calling
CN112015515A (en) Virtual network function instantiation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination