CN103902361A - Thread pool capable of dynamically adjusting size - Google Patents
Thread pool capable of dynamically adjusting size Download PDFInfo
- Publication number
- CN103902361A CN103902361A CN201410134889.2A CN201410134889A CN103902361A CN 103902361 A CN103902361 A CN 103902361A CN 201410134889 A CN201410134889 A CN 201410134889A CN 103902361 A CN103902361 A CN 103902361A
- Authority
- CN
- China
- Prior art keywords
- task
- thread
- management module
- thread pool
- pool
- 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
Links
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a thread pool capable of dynamically adjusting size and belongs to the field of computers. The thread pool is applicable to a situation that a large amount of threads are needed to complete a task and the time for completing the task is short, applications harsh in performance requirement so as to reduce time consumption for creating and destroying threads, and a large amount of sudden requests so as to prevent a server from creating a large amount of thread applications. The thread pool comprises a thread managing module for managing threads and distributing tasks, a task managing module for managing and scheduling the tasks, a task cache area for caching tasks issued by a user and a configuration file analyzing module for analyzing the configuration files used by the thread managing module and the task managing module. By the thread pool, thread creating and destroying efficiency is increased, the problem that the tasks cannot be executed due to the fact that thread creating fails is solved, and efficient and stable program operation is guaranteed.
Description
technical field
the present invention relates to computer realm, relate in particular to a kind of thread pool of capable of dynamic adjusting size.
Background technology
In object based programming, establishment and destruction are very time taking to liking, and will obtain memory source or other more resources because create an object.Be exactly to reduce as far as possible the number of times, the more very Object Creation in cost source and destruction that create and destroy object so improve means of service routine efficiency.How utilizing existing object to serve is exactly the key issue that needs solve.
Summary of the invention
Thread pool effect is exactly the quantity of execution thread in restriction system.According to the ambient conditions of system, can number of threads be set automatic or manual, reach the optimum efficiency of operation; Lack and wasted system resource, many caused the crowded efficiency of system not high.By thread pool control number of threads, other thread queuings wait.A tasks carrying is complete, then from queue, get top task start carry out.If there is no waiting process in queue, this resource of thread pool is in waiting for.In the time that a new task need to be moved, if there is the worker thread of wait in thread pool, just can bring into operation; Otherwise enter waiting list.
The present invention uses a kind of capable of dynamic to regulate the thread pool of size, improves thread execution efficiency, reduces system resources consumption.This thread pool adopts thread to reuse cache management to add task scheduling and manage the method combining and carry out thread pool management, mainly comprise:
(1) thread management module
In thread management module, comprise two chained lists, one is not use thread chained list, for preserving untapped thread information; Another is to have used thread chained list, for preserving the thread information having used.
A) increase thread
Search untapped thread information not using in thread chained list, then add to and used in thread chained list.
B) delete thread
Search the thread in dormant state using in thread chained list, then moved to and do not use in chained list.
C) task is processed timeout mechanism
Thread is executing the task in processing procedure, if be hampered plug, the time-out time that can specify by user waits for, if overtime, still without responding, this thread can be terminated, and the newly created threads of laying equal stress on is filled up the thread being terminated.
D) thread dormancy/activation
In the time that thread gets task, this thread can be activated.After it handles task, be set to dormancy.
E) thread allocating task mechanism
Thread obtains untreated task from task management module, and carries out this task.
(2) task management module
In task management module, there is a Task-list, for preserving pending mission bit stream.
A) increase task
By the task in task buffer memory, add in the Task-list in task management module.
B) deletion task
When thread management module obtains task, deletion task in the Task-list from task management module.
C) regulate thread pool size
According to the configuration information in configuration file, the size of dynamic adjustments thread pool, the namely Thread Count in thread management module.
D) task in scheduler task buffer memory
Task management module is searched the task that priority is higher from task buffer zone, puts into the Task-list priority processing of oneself.
(3) task buffer zone
In task buffer area, there is a Task-list, the mission bit stream importing into for cache user.
A) increase task
User's input information is increased in the Task-list of task buffer area.
B) deletion task
In the time of task management module schedules task buffer area task, deletion task from the Task-list of task buffer area, and be increased in the task list in task management module.
(4) profile management module
Profile management module, for reading thread pool configuration file, and resolves configuration file.Which type of thread pool size is the task in which quantitative range of can indicating in configuration file used.Thereby guarantee the efficiency optimization of thread pool.
Compared with prior art, the beneficial effect producing is in the present invention:
By introducing the management of this thread pool, can reduce the number of times that creates and destroy thread, each worker thread can be repeated to utilize, and can carry out multiple tasks; Can, according to the ability to bear of system, adjust the number of front thread in thread pool, prevent because because consume too much internal memory, and tired server falling, (each thread needs about 1MB internal memory, it is more that thread is opened, and the internal memory of consumption is also just larger, finally crashes); Reduce the number of times that creates and destroy thread, improved efficiency; Each worker thread can be repeated to utilize, and can carry out multiple tasks.
Accompanying drawing explanation
Accompanying drawing 1 is modular structure figure of the present invention.
Embodiment
Thread pool adopts thread to reuse cache management to add task scheduling and manage the method combining and carry out thread pool management, mainly comprise:
1), thread management module
In thread management module, comprise two chained lists, one is not use thread chained list, for preserving untapped thread information; Another is to have used thread chained list, for preserving the thread information having used.
F) increase thread
Search untapped thread information not using in thread chained list, then add to and used in thread chained list.
G) delete thread
Search the thread in dormant state using in thread chained list, then moved to and do not use in chained list.
H) task is processed timeout mechanism
Thread is executing the task in processing procedure, if be hampered plug, the time-out time that can specify by user waits for, if overtime, still without responding, this thread can be terminated, and the newly created threads of laying equal stress on is filled up the thread being terminated.
I) thread dormancy/activation
In the time that thread gets task, this thread can be activated.After it handles task, be set to dormancy.
J) thread allocating task mechanism
Thread obtains untreated task from task management module, and carries out this task.
2), task management module
In task management module, there is a Task-list, for preserving pending mission bit stream.
E) increase task
By the task in task buffer memory, add in the Task-list in task management module.
F) deletion task
When thread management module obtains task, deletion task in the Task-list from task management module.
G) regulate thread pool size
According to the configuration information in configuration file, the size of dynamic adjustments thread pool, the namely Thread Count in thread management module.
H) task in scheduler task buffer memory
Task management module is searched the task that priority is higher from task buffer zone, puts into the Task-list priority processing of oneself.
3), task buffer zone
In task buffer area, there is a Task-list, the mission bit stream importing into for cache user.
C) increase task
User's input information is increased in the Task-list of task buffer area.
D) deletion task
In the time of task management module schedules task buffer area task, deletion task from the Task-list of task buffer area, and be increased in the task list in task management module.
6), profile management module
Profile management module, for reading thread pool configuration file, and resolves configuration file.Which type of thread pool size is the task in which quantitative range of can indicating in configuration file used.Thereby guarantee the efficiency optimization of thread pool.
Thread management module is in charge of thread, allocating task; Task management module is in charge of task, scheduler task, adjusting thread pool size; Task buffer area is in charge of user's input information; Thread pool configuration file is responsible for reading, is resolved in configuration file management.
Claims (5)
1. the thread pool of a capable of dynamic adjusting size, it is characterized in that this thread pool composition comprises four parts, the one, thread management module is for management thread, allocating task, the 2nd, task management module is for management and dispatching task, the 3rd, the task that task buffer area issues from user for buffer memory, the 4th, the configuration file that configuration file parsing module uses for resolving thread management module and task management module; Adopting thread to reuse cache management adds task scheduling and manages the method combining and carry out thread pool management.
2. method according to claim 1, is characterized in that comprising two chained lists in described thread management module, and one is not use thread chained list, for preserving untapped thread information; Another is to have used thread chained list, for preserving the thread information having used; Thread management module comprises: increase thread, deletion thread, thread dormancy/activation, thread distribution mechanism, task processing timeout mechanism.
3. method according to claim 1, is characterized in that there is a Task-list in described task management module, for preserving pending mission bit stream; Task management module comprises: the task in increase task, deletion task, adjusting thread pool size, scheduler task buffer memory.
4. method according to claim 1, is characterized in that in described task buffer area, having a Task-list, the mission bit stream importing into for cache user; Task buffer area comprises: increase task, deletion task.
5. method according to claim 1, is characterized in that described profile management module comprises: read thread pool configuration file, resolve thread pool configuration file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410134889.2A CN103902361A (en) | 2014-04-04 | 2014-04-04 | Thread pool capable of dynamically adjusting size |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410134889.2A CN103902361A (en) | 2014-04-04 | 2014-04-04 | Thread pool capable of dynamically adjusting size |
Publications (1)
Publication Number | Publication Date |
---|---|
CN103902361A true CN103902361A (en) | 2014-07-02 |
Family
ID=50993700
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410134889.2A Pending CN103902361A (en) | 2014-04-04 | 2014-04-04 | Thread pool capable of dynamically adjusting size |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103902361A (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104572277A (en) * | 2014-12-17 | 2015-04-29 | 大唐移动通信设备有限公司 | Thread flow control method and thread flow control device |
CN105824691A (en) * | 2015-01-08 | 2016-08-03 | 平安科技(深圳)有限公司 | Method and device for dynamically regulating threads |
CN106407197A (en) * | 2015-07-28 | 2017-02-15 | 北京京东尚科信息技术有限公司 | Data traversing method and device |
CN106716367A (en) * | 2014-09-25 | 2017-05-24 | 甲骨文国际公司 | System and method for supporting dynamic thread pool sizing in distributed data grid |
CN107122193A (en) * | 2017-04-28 | 2017-09-01 | 湖南中车时代通信信号有限公司 | A kind of dynamic regulating method of message threads suspension time |
CN107220033A (en) * | 2017-07-05 | 2017-09-29 | 百度在线网络技术(北京)有限公司 | Method and apparatus for controlling thread pool thread quantity |
CN109542632A (en) * | 2018-11-30 | 2019-03-29 | 郑州云海信息技术有限公司 | A kind of method and device handling access request |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040093605A1 (en) * | 1998-11-13 | 2004-05-13 | Alverson Gail A. | Accessing a collection of data items in a multithreaded environment |
CN101364185A (en) * | 2008-09-02 | 2009-02-11 | 中国科学院软件研究所 | Thread pool size self-adapting regulating method and concurrency control method applying server |
CN102147746A (en) * | 2010-03-05 | 2011-08-10 | 微软公司 | Dynamic thread pool management |
CN102207890A (en) * | 2011-05-27 | 2011-10-05 | 苏州阔地网络科技有限公司 | Task information processing method and scheduling control processing device |
CN102541653A (en) * | 2010-12-24 | 2012-07-04 | 新奥特(北京)视频技术有限公司 | Method and system for scheduling multitasking thread pools |
CN102591721A (en) * | 2011-12-30 | 2012-07-18 | 北京新媒传信科技有限公司 | Method and system for distributing thread execution task |
CN103455377A (en) * | 2013-08-06 | 2013-12-18 | 北京京东尚科信息技术有限公司 | System and method for managing business thread pool |
-
2014
- 2014-04-04 CN CN201410134889.2A patent/CN103902361A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040093605A1 (en) * | 1998-11-13 | 2004-05-13 | Alverson Gail A. | Accessing a collection of data items in a multithreaded environment |
CN101364185A (en) * | 2008-09-02 | 2009-02-11 | 中国科学院软件研究所 | Thread pool size self-adapting regulating method and concurrency control method applying server |
CN102147746A (en) * | 2010-03-05 | 2011-08-10 | 微软公司 | Dynamic thread pool management |
CN102541653A (en) * | 2010-12-24 | 2012-07-04 | 新奥特(北京)视频技术有限公司 | Method and system for scheduling multitasking thread pools |
CN102207890A (en) * | 2011-05-27 | 2011-10-05 | 苏州阔地网络科技有限公司 | Task information processing method and scheduling control processing device |
CN102591721A (en) * | 2011-12-30 | 2012-07-18 | 北京新媒传信科技有限公司 | Method and system for distributing thread execution task |
CN103455377A (en) * | 2013-08-06 | 2013-12-18 | 北京京东尚科信息技术有限公司 | System and method for managing business thread pool |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106716367A (en) * | 2014-09-25 | 2017-05-24 | 甲骨文国际公司 | System and method for supporting dynamic thread pool sizing in distributed data grid |
CN106716367B (en) * | 2014-09-25 | 2020-12-08 | 甲骨文国际公司 | System and method for supporting dynamic thread pool size determination in a distributed data grid |
CN104572277A (en) * | 2014-12-17 | 2015-04-29 | 大唐移动通信设备有限公司 | Thread flow control method and thread flow control device |
CN104572277B (en) * | 2014-12-17 | 2018-04-27 | 大唐移动通信设备有限公司 | A kind of thread flow control method and device |
CN105824691A (en) * | 2015-01-08 | 2016-08-03 | 平安科技(深圳)有限公司 | Method and device for dynamically regulating threads |
CN105824691B (en) * | 2015-01-08 | 2019-11-22 | 平安科技(深圳)有限公司 | The method and device of dynamic regulation thread |
CN106407197A (en) * | 2015-07-28 | 2017-02-15 | 北京京东尚科信息技术有限公司 | Data traversing method and device |
CN106407197B (en) * | 2015-07-28 | 2020-06-30 | 北京京东尚科信息技术有限公司 | Method and device for traversing data |
CN107122193A (en) * | 2017-04-28 | 2017-09-01 | 湖南中车时代通信信号有限公司 | A kind of dynamic regulating method of message threads suspension time |
CN107122193B (en) * | 2017-04-28 | 2020-09-08 | 中国中车股份有限公司 | Dynamic adjustment method for message thread suspension time |
CN107220033A (en) * | 2017-07-05 | 2017-09-29 | 百度在线网络技术(北京)有限公司 | Method and apparatus for controlling thread pool thread quantity |
CN109542632A (en) * | 2018-11-30 | 2019-03-29 | 郑州云海信息技术有限公司 | A kind of method and device handling access request |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103902361A (en) | Thread pool capable of dynamically adjusting size | |
US10049133B2 (en) | Query governor across queries | |
CN101799773B (en) | Memory access method of parallel computing | |
CN111406250A (en) | Provisioning using prefetched data in a serverless computing environment | |
US10318346B1 (en) | Prioritized scheduling of data store access requests | |
CN104115093A (en) | Method, apparatus, and system for energy efficiency and energy conservation including power and performance balancing between multiple processing elements | |
CN105045607A (en) | Method for achieving uniform interface of multiple big data calculation frames | |
US8924754B2 (en) | Quality of service targets in multicore processors | |
Calafiura et al. | The ATLAS Event Service: A new approach to event processing | |
Nicolae et al. | Leveraging adaptive I/O to optimize collective data shuffling patterns for big data analytics | |
CN103455377A (en) | System and method for managing business thread pool | |
US20210004712A1 (en) | Machine Learning Performance and Workload Management | |
CN103049533A (en) | Method for quickly loading data into database | |
WO2013126415A3 (en) | Method and system for scheduling requests in a portable computing device | |
US20110167245A1 (en) | Task list generation, parallelism templates, and memory management for multi-core systems | |
Kaur et al. | Performance evaluation of task scheduling algorithms in virtual cloud environment to minimize makespan | |
CN105607956B (en) | Method for allocating tasks and system in a kind of computer | |
CN104683472A (en) | Data transmission method supporting large data volume | |
US20160034528A1 (en) | Co-processor-based array-oriented database processing | |
Govindarajan et al. | Task scheduling in big data-review, research challenges, and prospects | |
US10275289B2 (en) | Coexistence of message-passing-like algorithms and procedural coding | |
US9582340B2 (en) | File lock | |
CN102193831A (en) | Method for establishing hierarchical mapping/reduction parallel programming model | |
CN102375780A (en) | Metadata cache management method in distributed file system | |
US20170262487A1 (en) | Using Message-Passing With Procedural Code In A Database Kernel |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20140702 |