CN106940658A - Task processing method and device based on thread pool - Google Patents
Task processing method and device based on thread pool Download PDFInfo
- Publication number
- CN106940658A CN106940658A CN201710093555.9A CN201710093555A CN106940658A CN 106940658 A CN106940658 A CN 106940658A CN 201710093555 A CN201710093555 A CN 201710093555A CN 106940658 A CN106940658 A CN 106940658A
- Authority
- CN
- China
- Prior art keywords
- thread pool
- task
- sub
- thread
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Abstract
The disclosure discloses a kind of task processing method and device based on thread pool, belongs to field of computer technology.Methods described includes:The task refusal instruction in receiving thread pond, refuses the task that instruction acquisition is refused by the thread pool according to the task, the task is handled by the sub- thread pool of the thread pool.Above-mentioned task processing method and device based on thread pool can improve task disposal ability of the computer equipment based on thread pool.
Description
Technical field
This disclosure relates to Computer Applied Technology field, more particularly to a kind of task processing method and dress based on thread pool
Put.
Background technology
With the high speed development of Computer Applied Technology, computer equipment carries out task processing using thread pool mostly, i.e.,
Computer device resources are made full use of by way of multi-threading parallel process in thread pool, task treatment effeciency is improved.
However, the task disposal ability of each thread pool is limited, after a task is committed to thread pool, due to thread pool
Disposal ability such as transfinites at the reason, and the task will be refused by thread pool, and then cause the task to be abandoned, and cannot locate accordingly
Reason, so as to reduce the task disposal ability of computer equipment.
Fig. 1 is that the Java systems according to an exemplary embodiment carry the structural representation that thread pool carries out task processing
Figure.As shown in figure 1, when submitting task to thread pool, if the number of threads in thread pool is less than corePoolSize (thread pools
Core size), thread pool will create new thread and task is handled;If the number of threads in thread pool is not less than
CorePoolSize but less than maxPoolSize (maximum thread), task buffer queue less than when, task will be inserted
In task buffer queue, when task buffer queue is expired, new thread will be created task is handled;If but thread pool
In number of threads be not less than maxPoolSize, the task will be refused, the task is handled, so as to reduce calculating
The task disposal ability of machine equipment.
Therefore, when current computer equipment is based on thread pool progress task processing, it is impossible to refused in task by a thread pool
It is without offspring that the task is handled, cause task disposal ability relatively low.
The content of the invention
In order to solve the relatively low technical problem of the task disposal ability based on thread pool in correlation technique, present disclose provides
A kind of task processing method and device based on thread pool.
A kind of task processing method based on thread pool, including:
The task refusal instruction in receiving thread pond;
The task that instruction acquisition is refused by the thread pool is refused according to the task;
The task is handled by the sub- thread pool of the thread pool.
A kind of Task Processing Unit based on thread pool, including:
Module is rejected, the task for receiving thread pond refuses instruction;
Task acquisition module, being refused by the thread pool for task is obtained for refusing instruction according to the task;
Task processing module, for handling the task by the sub- thread pool of the thread pool.
The technical scheme provided by this disclosed embodiment can include the following benefits:
When carrying out task processing based on thread pool, refuse to instruct by the task in receiving thread pond, refused according to task
Instruction obtains being refused by thread pool for task, and then handles the task using the sub- thread pool of thread pool, it is to avoid task is because by line
Cheng Chi refuses and cannot handled, so that task is handled parallel using the sub- thread pool of the thread pool and the thread pool,
Substantially increase the task disposal ability of computer equipment.
It should be appreciated that the general description of the above and detailed description hereinafter are only exemplary, this can not be limited
It is open.
Brief description of the drawings
Accompanying drawing herein is merged in specification and constitutes the part of this specification, shows the implementation for meeting the present invention
Example, and in specification together for explaining principle of the invention.
Fig. 1 is that the Java systems according to an exemplary embodiment carry the structural representation that thread pool carries out task processing
Figure;
Fig. 2 is a kind of task processing method flow chart based on thread pool according to an exemplary embodiment;
Fig. 3 is another task processing method flow chart based on thread pool for correspondingly being implemented to exemplify according to Fig. 2;
Fig. 4 is another task processing method flow chart based on thread pool for correspondingly being implemented to exemplify according to Fig. 2;
Fig. 5 is another task processing method flow chart based on thread pool for correspondingly being implemented to exemplify according to Fig. 2;
Fig. 6 be Fig. 2 correspondence embodiments the task processing method based on thread pool in step S150 one kind implement
Flow chart;
Fig. 7 is that a kind of concrete application scene of task processing based on thread pool according to an exemplary embodiment is shown
It is intended to;
Fig. 8 is a kind of block diagram of Task Processing Unit based on thread pool according to an exemplary embodiment;
Fig. 9 is the block diagram of another Task Processing Unit based on thread pool for correspondingly being implemented to exemplify according to Fig. 8;
Figure 10 is the block diagram of another Task Processing Unit based on thread pool for correspondingly being implemented to exemplify according to Fig. 8;
Figure 11 is the block diagram of another Task Processing Unit based on thread pool for correspondingly being implemented to exemplify according to Fig. 8;
Figure 12 is correspondingly to implement task processing module in the Task Processing Unit based on thread pool that exemplifies according to Fig. 8
150 block diagram;
Figure 13 is a kind of schematic diagram of implementation environment Computer equipment according to an exemplary embodiment.
Embodiment
Here explanation will be performed to exemplary embodiment in detail, its example is illustrated in the accompanying drawings.Following description is related to
During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment
Described in embodiment do not represent and the consistent all embodiments of the present invention.On the contrary, they be only with it is such as appended
The example of the consistent apparatus and method of some aspects be described in detail in claims, the present invention.
In one embodiment, this disclosure relates to implementation environment include:Computer equipment and it is installed in computer equipment
On task processing module.Wherein, computer equipment has a SOS, independent operating space, can install software with
And the software that the third party service provider provides, for example, computer equipment can be various intelligence system processing equipments etc..Task processing
Module is the hardware module that can be handled based on thread pool task.
Fig. 2 is a kind of task processing method flow chart based on thread pool according to an exemplary embodiment.Such as Fig. 2
It is shown, it is somebody's turn to do the task processing method based on thread pool and may comprise steps of.
In step s 110, the task refusal instruction in receiving thread pond.
Thread pool is that task is added into task buffer queue, Ran Hou in a kind of multiple threads form, processing procedure
These tasks are performed automatically after creating thread.After tasks carrying is finished, the thread will be reclaimed automatically.
Thread is also referred to as Lightweight Process (LightWeight Process, LWP), is the minimum list that program performs stream
Member.
Task refusal instruction is the instruction that thread pool is sent for the task that refusal receives.
It is understood that the task disposal ability of each thread pool is limited in computer equipment.When the task of thread pool
When amount transfinites, it will refuse to receive new task, and task refusal instruction is sent for the task.
Thus, after thread pool sends task refusal instruction for task, computer equipment will receive task refusal
Instruction.
In a specific exemplary embodiment, thread pool A maximum thread is maxPoolSize.As thread pool A
In number of threads reach maxPoolSize, and task buffer queue is full, if now still submitting new appoint to thread pool A
Business, thread pool A will refuse to receive the task, and send task refusal instruction for the task.
In step s 130, the task that instruction acquisition is refused by thread pool is refused according to task.
It is understood that each task has its corresponding identification information in computer equipment.
It should be noted that task refusal instruction is that thread pool is sent for the refusal of some task, task refusal
Include the identification information of the task in instruction, such as task sequence number.
The identification information thus refused according to task in instruction can find being rejected for task.
In step S150, pass through the sub- thread pool process task of thread pool.
Sub- thread pool is the dependent thread pond for belonging to some thread pool in computer equipment.
The reference of the thread pool belonged to it is saved in sub- thread pool, the task buffer in the thread pool of its ownership is shared
List, so as to the task buffer queue for the thread pool for obtaining its ownership, and then assists its thread pool belonged to carry out task
Processing.
For example, computer equipment there are thread pool A and sub- thread pool B, sub- thread pool B is thread pool A thread pool,
Sub- thread pool B can obtain thread pool A task buffer list.
After sub- thread pool reception task, the thread new by creating performs being rejected for task, so that the task is obtained
Processing.
Using method as described above, after task is refused by thread pool, by the sub- thread pool of the thread pool to this
Business is handled, it is to avoid go out the phenomenon that current task cannot be handled, and substantially increases the energy that task processing is carried out based on thread pool
Power.
Fig. 3 is a kind of task processing method flow chart based on thread pool according to an exemplary embodiment.Such as Fig. 3
It is shown, before correspondingly implementing the step S150 that exemplifies in Fig. 2, should task processing method based on thread pool can also include with
Lower step.
In step S210, judge that thread pool whether there is sub- thread pool, if NO (N), then perform step S230, if
It is (Y), then performs step S150.
After being refused by thread pool for task is obtained, by having judged whether that thread pool is subordinated to the thread pool, enter
And determine the thread pool and whether there is sub- thread pool.
Judge whether that thread pool is subordinated to the thread pool, that is, judged that the thread pool can be with the presence or absence of sub- thread pool
By judging whether the thread pool to other thread pools shares task buffer queue.
It should be noted that thread pool to other thread pools share task buffer queue when, will in the thread pool add
Task sharing information.
Thus, by searching task sharing information in each thread pool, find the thread added with task sharing information
Chi Hou, determines to share the sub- thread pool of task buffer queue in the thread pool according to task sharing information.
When sub- thread pool is not present in the thread pool for refusing task, then sub- thread pool is created for the thread pool;When refusal is appointed
When the thread pool of business there are sub- thread pool, then pass through sub- thread pool process task.
It is that thread pool creates sub- thread pool in step S230.
According to the task buffer list of thread pool, a dependent thread pond, i.e., sub- thread pool are set up for the thread pool, and set
The task buffer list for putting the thread pool is shared to sub- thread pool.
When creating sub- thread pool, task sharing information is added in thread pool, so that sub- thread pool can share the thread
Task buffer queue in pond, realization is monitored to the task in the thread pool.
In a specific exemplary embodiment, after the thread pool reception task that task disposal ability transfinites, by pin
Task refusal instruction is sent to the task.Refused to instruct according to the task, when sub- thread pool is not present in the thread pool, application is
The thread pool creates sub- thread pool, and then performs being refused by thread pool for task by the thread of the sub- thread pool.
By method as described above, after thread pool is refused task, when the thread pool, which is not present, sub- thread pool, it is
The thread pool creates sub- thread pool, and then handles being refused by the thread pool for task by sub- thread pool, it is to avoid goes out current task and obtains
Less than the phenomenon of processing, the ability that task processing is carried out based on thread pool is substantially increased.
Fig. 4 is a kind of task processing method flow chart based on thread pool according to an exemplary embodiment.Such as Fig. 4
It is shown, correspondingly implement to comprise the following steps after the step S150 that exemplifies in Fig. 2.
In step S310, whether the task buffer queue for judging sub- thread pool is empty, if yes (Y), then performs step
S330, if NO (N), then performs step S311.
It is understood that sub- thread pool is to carry out task processing for the thread pool for assisting it to belong to.
The task buffer queue of group thread pool is space-time, shows that the task executed of sub- thread pool processing is finished, sub-line
Cheng Chi is now in idle condition.For the thread pool progress task processing for further assisting it to belong to, the thread pool belonged to from it
Middle extraction is gone out on missions, so as to reduce the task treating capacity of the thread pool of its ownership, is improved computer equipment and is carried out based on thread pool
The ability of task processing.
The task buffer queue of group thread pool is not space-time, and sub- thread pool then continues with its own task buffer queue
In task.
In a specific exemplary embodiment, when carrying out task processing using sub- thread pool, according to sub- thread pool certainly
Each task puts in order in body task buffer queue, extracts task from task buffer queue successively, then pass through sub- thread pool
Thread carry out tasks carrying;After tasks carrying in sub- thread pool itself task buffer queue is finished, return from sub- thread pool
Task is extracted in the task buffer queue of the thread pool of category, then the task is performed by the thread of sub- thread pool, until sub-line journey
And the respective task buffer queue of thread pool of sub-line journey ownership is sky.
In step S330, task is extracted from the task buffer queue of thread pool.
In step S311, the task in task buffer queue is continued with.
In step S350, using the thread execution task of sub- thread pool.
Using method as described above, its thread pool belonged to is assisted to carry out task processing by sub- thread pool, in sub-line
Cheng Chi task buffer queue is space-time, is gone out on missions by being extracted from the thread pool that it belongs to, then using in sub- thread pool
Thread performs the task, so as to carry out task processing parallel by multiple thread pools, accelerates the speed of task processing, improves
The task disposal ability of thread pool.
Fig. 5 is another task processing method flow chart based on thread pool according to an exemplary embodiment.Such as
Correspondingly implement to comprise the following steps after the step S150 that exemplifies shown in Fig. 5, in Fig. 2.
In step S410, task buffer queue detection is carried out to the sub- thread pool of thread pool and thread pool respectively.
Task buffer queue detection is detected to whether also there is being not carried out for task in task buffer queue.
In step S430, task buffer queue is space-time in the sub- thread pool of thread pool and thread pool, destroys line
Cheng Chi thread pool.
It is understood that when in the sub- thread pool of thread pool and the thread pool task buffer queue be space-time, show
The processed task of sub- thread pool of thread pool and the thread pool is finished, now, and the sub- thread pool of thread pool and the thread pool is equal
In idle condition, tasks carrying is had no.
Therefore, if task buffer queue is space-time in the sub- thread pool of thread pool and the thread pool, sub-line journey is still retained
Pond, will cause system resource waste.Now, even if there is new task to need processing, the thread pool also can be performed accordingly, destroy son
Thread pool does not interfere with task disposal ability yet.But by destroying the sub- thread pool of the thread pool, it can but avoid system resource
Waste.
Using method as described above, task buffer queue is sky in the sub- thread pool of thread pool and the thread pool
When, the sub- thread pool of the thread pool is destroyed, so as to avoid the waste of system resource when not influenceing task to handle.
Fig. 6 is the description to step S150 details in Fig. 2 according to an exemplary embodiment.Step S150 can
To comprise the following steps.
In step S151, in the task buffer queue that task is inserted to sub- thread pool.
It should be noted that when thread pool carries out task processing, task is first inserted to the task buffer queue of thread pool, when
When the thread of thread pool is not up to thread capacity, the task in the thread execution task buffer queue new by creating.
Sub- thread pool is received after new task, in the task buffer queue that the task is inserted to its own, for sub-line journey
Pond created and performed after thread.
In step S153, judge whether the number of threads of sub- thread pool reaches default thread capacity, if NO (N), then
Step S155 is performed, if yes (Y), then the task in the task buffer queue of sub- thread pool wouldn't be handled.
It should be noted that thread pool is preset with thread capacity.By being controlled to the number of threads in thread pool,
Avoid because of thread occupying system resources excessive in thread pool and caused by system crash.
When number of threads in group thread pool is not up to default thread capacity, by creating new line in sub- thread pool
Journey is handled the task in task buffer queue;When the number of threads of group thread pool reaches default thread capacity, need
Handled after the tasks carrying being carrying out is finished, then to the task in task buffer queue.
In step S155, pass through the task in the thread execution task buffer queue of sub- thread pool.
Using method as described above, when the number of threads of sub- thread pool is not up to default thread capacity, using sub-line
Cheng Chi thread carries out performing the task in task buffer queue, it is to avoid reach that default thread holds in the number of threads of sub- thread pool
Thread execution task is still created after amount, causes excessive occupying system resources and causes system crash.
The task processing method based on thread pool as above is elaborated with reference to a specific application scenarios.Base
Run in the task processing method of thread pool in a computer equipment, specifically, as shown in Figure 7.
Task is submitted to father's thread pool.
Judge whether father's thread pool reaches maximum processing capability.If father's thread pool is not up to maximum processing capability, pass through
Father's thread pool is handled the task;If father's thread pool reaches maximum processing capability, father's thread pool is sent for the task
Task refusal instruction, the task that instruction lookup is refused by father's thread pool is refused according to task.
Judge that father's thread pool whether there is sub- thread pool.If father's thread pool has sub- thread pool, the task is inserted into son
In the task buffer queue of thread pool;If sub- thread pool is not present in father's thread pool, sub- thread pool is created for father's thread pool, and will
The task is inserted in the task buffer queue of sub- thread pool.
Pass through the task in the thread execution task buffer queue of sub- thread pool.
Whether the task buffer queue for judging sub- thread pool is empty.The task buffer queue of group thread pool is space-time, is sentenced
Whether the task buffer queue of disconnected father's thread pool is empty.When whether the task buffer queue of father's thread pool is empty, from father's thread pool
Task buffer queue in extract task, and task is inserted in the task buffer queue of sub- thread pool.
When task buffer queue is space-time in the sub- thread pool of father's thread pool and father's thread pool, father's thread pool is destroyed
Sub- thread pool.
Following is disclosure device embodiment, can be used for performing this above-mentioned task processing method implementation based on thread pool
Example.For the details not disclosed in disclosure device embodiment, task processing method of the disclosure based on thread pool refer to real
Apply example.
Fig. 8 is a kind of block diagram of Task Processing Unit based on thread pool according to an exemplary embodiment, the dress
Put including but not limited to:Reject module 110, task acquisition module 130 and task processing module 150.
Module 110 is rejected, the task for receiving thread pond refuses instruction;
Task acquisition module 130, being refused by the thread pool for task is obtained for refusing instruction according to the task;
Task processing module 150, for handling the task by the sub- thread pool of the thread pool.
The function of modules and the implementation process of effect specifically refer to the above-mentioned task based on thread pool in said apparatus
The implementation process of correspondence step, will not be repeated here in processing method.
Optionally, as shown in figure 9, the Task Processing Unit based on thread pool shown in Fig. 8 also includes but is not limited to:Son
Thread pool judge module 210 and sub- thread pool creation module 230.
Sub- thread pool judge module 210, for judging that the thread pool whether there is sub- thread pool;
Sub- thread pool creation module 230, for being that the thread pool is created when sub- thread pool is not present in the thread pool
Sub- thread pool.
Optionally, as shown in Figure 10, the Task Processing Unit based on thread pool shown in Fig. 8 also includes but is not limited to:
Task buffer queue judge module 310, task extraction module 330 and task execution module 350.
Task buffer queue judge module 310, whether the task buffer queue for judging the sub- thread pool is empty;
Task extraction module 330, is space-time for the task buffer queue when the sub- thread pool, from the thread pool
Task is extracted in task buffer queue;
Task execution module 350, for performing the task using the thread of the sub- thread pool.
Optionally, as shown in figure 11, the Task Processing Unit based on thread pool shown in Fig. 8 also includes but is not limited to:
Task buffer queue detection module 410 and sub- thread pool destroy module 430.
Task buffer queue detection module 410, for entering respectively to the sub- thread pool of the thread pool and the thread pool
Row task buffer queue detection;
Sub- thread pool destroys module 430, for the task buffer in the sub- thread pool of the thread pool and the thread pool
Queue is space-time, destroys the sub- thread pool of the thread pool.
Optionally, as shown in figure 12, the task processing module 150 in Fig. 8 includes but is not limited to:Task placement unit 151,
Number of threads judging unit 153 and task executing units 155.
Task placement unit 151, for the task to be inserted in the task buffer queue of the sub- thread pool;
Number of threads judging unit 153, for judging whether the number of threads of the sub- thread pool reaches that default thread holds
Amount;
Task executing units 155, for when the number of threads of the sub- thread pool is not up to default thread capacity, passing through
The sub- thread pool creates the task in the new thread execution task buffer queue.
Figure 13 is a kind of block diagram of terminal 100 according to an exemplary embodiment.Terminal 100 can apply to above-mentioned
Computer equipment in implementation environment.
With reference to Figure 13, terminal 100 can include one or more following component:Processing assembly 101, memory 102, electricity
Source component 103, multimedia groupware 104, audio-frequency assembly 105, sensor cluster 107 and communication component 108.Wherein, above-mentioned group
Part is simultaneously not all necessary, and terminal 100 can increase other assemblies according to itself functional requirement or reduce some components, this implementation
Example is not construed as limiting.
The integrated operation of the usual control terminal 100 of processing assembly 101, such as with display, call, data communication, phase
Operation that machine is operated and record operation is associated etc..Processing assembly 101 can include one or more processors 109 to perform
Instruction, to complete all or part of step of aforesaid operations.In addition, processing assembly 101 can include one or more modules, just
Interaction between processing assembly 101 and other assemblies.For example, processing assembly 101 can include multi-media module, it is many to facilitate
Interaction between media component 104 and processing assembly 101.
Memory 102 is configured as storing various types of data supporting the operation in terminal 100.These data are shown
Example includes the instruction of any application program or method for operating on the terminal 100.Memory 102 can be by any kind of
Volatibility or non-volatile memory device or combinations thereof realization, such as SRAM (Static Random Access
Memory, static RAM), EEPROM (Electrically Erasable Programmable Read-
Only Memory, Electrically Erasable Read Only Memory), EPROM (Erasable Programmable Read Only
Memory, Erasable Programmable Read Only Memory EPROM), (Programmable Read-Only Memory may be programmed read-only PROM
Memory), ROM (Read-Only Memory, read-only storage), magnetic memory, flash memory, disk or CD.Storage
Also be stored with one or more modules in device 102, and one or more modules are configured to by the one or more processors 109
Perform, to complete all or part of step in any shown method of Fig. 2, Fig. 3, Fig. 4, Fig. 5 and Fig. 6.
Power supply module 103 provides electric power for the various assemblies of terminal 100.Power supply module 103 can include power management system
System, one or more power supplys, and other components associated with generating, managing and distributing electric power for terminal 100.
Multimedia groupware 104 is included in the screen of one output interface of offer between the terminal 100 and user.One
In a little embodiments, screen can include LCD (Liquid Crystal Display, liquid crystal display) and TP (Touch
Panel, touch panel).If screen includes touch panel, screen may be implemented as touch-screen, to receive from user's
Input signal.Touch panel includes one or more touch sensors with the gesture on sensing touch, slip and touch panel.Institute
State touch sensor can not only sensing touch or sliding action border, but also detection touches or slide phase with described
The duration of pass and pressure.
Audio-frequency assembly 105 is configured as output and/or input audio signal.For example, audio-frequency assembly 105 includes a Mike
Wind, when terminal 100 is in operator scheme, when such as call model, logging mode and speech recognition mode, microphone is configured as connecing
Receive external audio signal.The audio signal received can be further stored in memory 102 or be sent out via communication component 108
Send.In certain embodiments, audio-frequency assembly 105 also includes a loudspeaker, for exports audio signal.
Sensor cluster 107 includes one or more sensors, and the state for providing various aspects for terminal 100 is commented
Estimate.For example, sensor cluster 107 can detect opening/closed mode of terminal 100, the relative positioning of component, sensor group
Part 107 can also detect the position change and the temperature change of terminal 100 of 100 1 components of terminal 100 or terminal.At some
In embodiment, the sensor cluster 107 can also include Magnetic Sensor, pressure sensor or temperature sensor.
Communication component 108 is configured to facilitate the communication of wired or wireless way between terminal 100 and other equipment.Terminal
100 can access the wireless network based on communication standard, such as WiFi (WIreless-Fidelity, wireless network), 2G or 3G,
Or combinations thereof.In one exemplary embodiment, communication component 108 is received from external broadcasting management via broadcast channel
The broadcast singal or broadcast related information of system.In one exemplary embodiment, the communication component 108 also includes NFC
(Near Field Communication, near-field communication) module, to promote junction service.For example, can be based in NFC module
RFID (Radio Frequency Identification, radio frequency identification) technology, IrDA (Infrared
DataAssociation, Infrared Data Association) technology, UWB (Ultra-Wideband, ultra wide band) technology, BT
(Bluetooth, bluetooth) technology and other technologies are realized.
In the exemplary embodiment, terminal 100 can be by one or more ASIC (Application Specific
Integrated Circuit, application specific integrated circuit), DSP is (at Digital Signal Processing, data signal
Manage device), PLD (Programmable Logic Device, PLD), FPGA (Field-Programmable
GateArray, field programmable gate array), controller, microcontroller, microprocessor or other electronic components realize, for holding
The above-mentioned task processing method based on thread pool of row.
The concrete mode of the computing device operation of terminal in the embodiment is about the task based on thread pool
Detailed description is performed in the embodiment of processing method, explanation will be no longer elaborated herein.
In the exemplary embodiment, a kind of storage medium is additionally provided, the storage medium is computer-readable recording medium,
For example can be to include the provisional and non-transitorycomputer readable storage medium of instruction.The storage medium is for example including instruction
Memory 102, above-mentioned instruction can be performed by the processor 109 of terminal 100 with complete it is above-mentioned based on thread pool task processing
Method.
It should be appreciated that the invention is not limited in the precision architecture for being described above and being shown in the drawings, and
And various modifications and changes can be being performed without departing from the scope.The scope of the present invention is only limited by appended claim.
Claims (10)
1. a kind of task processing method based on thread pool, it is characterised in that methods described includes:
The task refusal instruction in receiving thread pond;
The task that instruction acquisition is refused by the thread pool is refused according to the task;
The task is handled by the sub- thread pool of the thread pool.
2. according to the method described in claim 1, it is characterised in that the sub- thread pool by the thread pool handles described
Before task step, methods described also includes:
Judge that the thread pool whether there is sub- thread pool, if it has not, sub- thread pool then is created for the thread pool, if it is,
Then
Perform the step of sub- thread pool by the thread pool handles the task.
3. according to the method described in claim 1, it is characterised in that the sub- thread pool by the thread pool handles described
After task step, methods described also includes:
Whether the task buffer queue for judging the sub- thread pool is empty, if it has, then
Task is extracted from the task buffer queue of the thread pool;
The task is performed using the thread of the sub- thread pool.
4. according to the method described in claim 1, it is characterised in that the sub- thread pool by the thread pool handles described
After task step, methods described also includes:
Task buffer queue detection is carried out to the sub- thread pool of the thread pool and the thread pool respectively;
Task buffer queue is space-time in the sub- thread pool of the thread pool and the thread pool, destroys the thread pool
Sub- thread pool.
5. according to the method described in claim 1, it is characterised in that the sub- thread pool by the thread pool handles described
Task, including:
In the task buffer queue that the task is inserted to the sub- thread pool;
Judge whether the number of threads of the sub- thread pool reaches default thread capacity, if it has not, then
The task in the new thread execution task buffer queue is created by the sub- thread pool.
6. a kind of Task Processing Unit based on thread pool, it is characterised in that described device includes:
Module is rejected, the task for receiving thread pond refuses instruction;
Task acquisition module, being refused by the thread pool for task is obtained for refusing instruction according to the task;
Task processing module, for handling the task by the sub- thread pool of the thread pool.
7. device according to claim 6, it is characterised in that described device also includes:
Sub- thread pool judge module, for judging that the thread pool whether there is sub- thread pool;
Sub- thread pool creation module, for being that the thread pool creates sub-line journey when sub- thread pool is not present in the thread pool
Pond.
8. device according to claim 6, it is characterised in that described device also includes:
Task buffer queue judge module, whether the task buffer queue for judging the sub- thread pool is empty;
Task extraction module, for being space-time when the task buffer queue of the sub- thread pool, delays from the task of the thread pool
Deposit and task is extracted in queue;
Task execution module, for performing the task using the thread of the sub- thread pool.
9. device according to claim 6, it is characterised in that described device also includes:
Task buffer queue detection module, delays for the sub- thread pool progress task respectively to the thread pool and the thread pool
Deposit queue detection;
Sub- thread pool destroys module, in the sub- thread pool of the thread pool and the thread pool task buffer queue be
Space-time, destroys the sub- thread pool of the thread pool.
10. device according to claim 6, it is characterised in that the task processing module includes:
Task placement unit, for the task to be inserted in the task buffer queue of the sub- thread pool;
Number of threads judging unit, for judging whether the number of threads of the sub- thread pool reaches default thread capacity;
Task executing units, for when the number of threads of the sub- thread pool is not up to default thread capacity, passing through the son
Thread pool creates the task in the new thread execution task buffer queue.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710093555.9A CN106940658B (en) | 2017-02-21 | 2017-02-21 | Task processing method and device based on thread pool |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710093555.9A CN106940658B (en) | 2017-02-21 | 2017-02-21 | Task processing method and device based on thread pool |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106940658A true CN106940658A (en) | 2017-07-11 |
CN106940658B CN106940658B (en) | 2022-09-09 |
Family
ID=59468660
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710093555.9A Active CN106940658B (en) | 2017-02-21 | 2017-02-21 | Task processing method and device based on thread pool |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106940658B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107741922A (en) * | 2017-10-18 | 2018-02-27 | 山东浪潮通软信息科技有限公司 | A kind of operational formula treating method and apparatus |
CN108846632A (en) * | 2018-05-28 | 2018-11-20 | 浙江口碑网络技术有限公司 | Thread processing method and device |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1588316A (en) * | 2004-06-29 | 2005-03-02 | 北京大学 | Property optimizing method for applying server |
US7237242B2 (en) * | 2002-12-31 | 2007-06-26 | International Business Machines Corporation | Dynamic thread pool tuning techniques |
CN103455377A (en) * | 2013-08-06 | 2013-12-18 | 北京京东尚科信息技术有限公司 | System and method for managing business thread pool |
CN105159768A (en) * | 2015-09-09 | 2015-12-16 | 浪潮集团有限公司 | Task management method and cloud data center management platform |
CN106095590A (en) * | 2016-07-21 | 2016-11-09 | 联动优势科技有限公司 | A kind of method for allocating tasks based on thread pool and device |
CN106155803A (en) * | 2015-04-07 | 2016-11-23 | 北大方正集团有限公司 | A kind of thread pool sharing method based on semaphore and system |
-
2017
- 2017-02-21 CN CN201710093555.9A patent/CN106940658B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7237242B2 (en) * | 2002-12-31 | 2007-06-26 | International Business Machines Corporation | Dynamic thread pool tuning techniques |
CN1588316A (en) * | 2004-06-29 | 2005-03-02 | 北京大学 | Property optimizing method for applying server |
CN103455377A (en) * | 2013-08-06 | 2013-12-18 | 北京京东尚科信息技术有限公司 | System and method for managing business thread pool |
CN106155803A (en) * | 2015-04-07 | 2016-11-23 | 北大方正集团有限公司 | A kind of thread pool sharing method based on semaphore and system |
CN105159768A (en) * | 2015-09-09 | 2015-12-16 | 浪潮集团有限公司 | Task management method and cloud data center management platform |
CN106095590A (en) * | 2016-07-21 | 2016-11-09 | 联动优势科技有限公司 | A kind of method for allocating tasks based on thread pool and device |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107741922A (en) * | 2017-10-18 | 2018-02-27 | 山东浪潮通软信息科技有限公司 | A kind of operational formula treating method and apparatus |
CN108846632A (en) * | 2018-05-28 | 2018-11-20 | 浙江口碑网络技术有限公司 | Thread processing method and device |
Also Published As
Publication number | Publication date |
---|---|
CN106940658B (en) | 2022-09-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104239094B (en) | Control method, device and the terminal device of background application | |
CN107786730A (en) | A kind of task management method and terminal | |
CN105225096A (en) | The disposal route of reminder announced message, device and terminal | |
CN104375828A (en) | Method and device for optimizing memory | |
CN105204915A (en) | Application program updating method, device and system | |
CN106598393A (en) | Split-screen display method and device | |
CN104299001A (en) | Photograph album generating method and device | |
CN103941969A (en) | Menu display method and device | |
CN104766005A (en) | Management method and device for application software access authority | |
CN104951335A (en) | Processing method and device for application program installation packages | |
CN104899610A (en) | Picture classification method and device | |
CN104536787B (en) | Resource preloads method and device | |
CN105808305A (en) | Static resource loading method and device | |
CN107765853A (en) | Using method for closing, device, storage medium and electronic equipment | |
CN105487886A (en) | Method and device for loading plugin | |
CN107219992A (en) | Open the method and device of split screen function | |
CN105139033A (en) | Classifier construction method and device and image processing method and device | |
CN104503690A (en) | Arrangement method and device for application icons | |
CN106648730A (en) | Processing method and device of abnormal application | |
CN104636170A (en) | Application acquiring method and device and electronic device | |
CN105302572A (en) | Method and device for importing file into software | |
CN107544802A (en) | device identification method and device | |
CN106339260A (en) | Task allocation method and device for Jenkins platform | |
CN106940658A (en) | Task processing method and device based on thread pool | |
CN105278836A (en) | Content switching method and apparatus, and terminal |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |