CN109783229A - The method and device of thread resources distribution - Google Patents
The method and device of thread resources distribution Download PDFInfo
- Publication number
- CN109783229A CN109783229A CN201811541874.2A CN201811541874A CN109783229A CN 109783229 A CN109783229 A CN 109783229A CN 201811541874 A CN201811541874 A CN 201811541874A CN 109783229 A CN109783229 A CN 109783229A
- Authority
- CN
- China
- Prior art keywords
- task
- thread
- mentioned
- child resource
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 56
- 238000012545 processing Methods 0.000 claims abstract description 98
- 238000004590 computer program Methods 0.000 claims description 8
- 238000004891 communication Methods 0.000 description 44
- 230000001960 triggered effect Effects 0.000 description 14
- 238000010586 diagram Methods 0.000 description 12
- 238000012986 modification Methods 0.000 description 10
- 230000004048 modification Effects 0.000 description 10
- 238000013507 mapping Methods 0.000 description 6
- 238000004422 calculation algorithm Methods 0.000 description 5
- 238000004364 calculation method Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 4
- 239000000284 extract Substances 0.000 description 3
- 238000004064 recycling Methods 0.000 description 2
- 239000002699 waste material Substances 0.000 description 2
- 230000006399 behavior Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
Abstract
The embodiment of the present application discloses a kind of method and device of thread resources distribution, this method is suitable for Business Process Optimizing, this method comprises: the receiving target service triggering of the task handles request, the task identification and task priority for requesting the goal task of processing are determined;If the task priority of the goal task is the first priority, target child resource thread pool corresponding with the goal task is determined according to the task identification;If the thread resources for being used to execute other tasks in target child resource thread pool progress thread resources are redistributed to obtain the subject thread resource for being used to execute the goal task not for executing the idle thread resource of the goal task in the target child resource thread pool;The goal task is executed based on the subject thread resource.The advantages of the embodiment of the present application uses the embodiment of the present application, has the inclination that can be realized when distributing thread resources to important service, improves the allocation flexibility of thread resources.
Description
Technical field
This application involves the method and devices that field of computer technology more particularly to a kind of thread resources are distributed.
Background technique
Comprehensive universal with network technology with the development of science and technology, demand of the people to all kinds of business is further vigorous,
Increasingly higher demands also proposed for the processing level of computer.In the server journey based on client-side/server-side mode
In sequence, in order to make full use of existing hardware resource, it has been proposed that multithreading solves the problems, such as that multiple threads concurrently execute.
But if there are many concurrent number of threads, and per thread is all to execute a time very short task just to finish, this
Sample frequently creates thread just and will be greatly reduced the efficiency of system, because frequently creation thread and destroying threads need the time.It is based on
This, in order to reduce the creation time of thread and destroy the time, people have also been proposed Thread Pool Technology, thread are multiplexed,
A task has exactly been executed, it is not destroyed, but other tasks can be continued to execute.However, such mode thread
Multiplexed form it is single, flexibility is poor, and applicability is not high.
Summary of the invention
The embodiment of the present application provides a kind of method and device of thread resources distribution, it can be achieved that thread resources are to important service
Inclination, improve the allocation flexibility of thread resources, applicability is high.
In a first aspect, the embodiment of the present application provides a kind of method of thread resources distribution, this method comprises:
The receiving target service triggering of the task handles request, determines that above-mentioned task processing requests the target of processing to be appointed
The task identification and task priority of business;
If the task priority of above-mentioned goal task is the first priority, according to the determination of above-mentioned task identification and above-mentioned mesh
The corresponding target child resource thread pool of mark task;
If, will be upper not for executing the idle thread resource of above-mentioned goal task in above-mentioned target child resource thread pool
It states in target child resource thread pool and redistributes for executing the thread resources progress thread resources of other tasks to obtain and be used for
Executing the subject thread resource of above-mentioned goal task, the task priority of other above-mentioned tasks includes the second priority, and above-mentioned the
Processing sequence of the processing sequence of the corresponding task of one priority prior to the corresponding task of above-mentioned second priority;
Above-mentioned goal task is executed based on above-mentioned subject thread resource.
With reference to first aspect, in a kind of possible embodiment, the task processing of above-mentioned reception target service triggering is asked
Before asking, the above method further include:
Resource thread pool comprising multiple thread resources is divided into multiple child resource thread pools, wherein a child resource
Include at least one thread resources in thread pool, includes at least above-mentioned target child resource thread in above-mentioned multiple child resource thread pools
Pond;
Set the thread pool mark of each child resource thread pool in above-mentioned multiple child resource thread pools;
Wherein, the thread pool of any child resource thread pool is identified for determining the thread in any of the above-described child resource thread pool
Task of the resource for execution.
With reference to first aspect, above-mentioned according to the determination of above-mentioned task identification and above-mentioned mesh in a kind of possible embodiment
The corresponding target child resource thread pool of mark task includes:
The corresponding subject thread of above-mentioned task identification is determined from the thread pool of above-mentioned each child resource thread pool mark
Above-mentioned subject thread pond is identified corresponding child resource thread pool and is determined as target corresponding with above-mentioned goal task by pond mark
Resource thread pool.
With reference to first aspect, in a kind of possible embodiment, at the above-mentioned above-mentioned task processing request institute's request of determination
Before the task identification and task priority of the goal task of reason, the above method further include:
At least two task types are obtained, the task of same task type is by same in above-mentioned at least two task type
Business mark label;
Set the corresponding task priority of various task types in above-mentioned at least two task type, above-mentioned task priority
In include at least above-mentioned first priority and above-mentioned second priority, the corresponding task priority of above-mentioned various task types is used for
Determine the processing sequence of the task of above-mentioned various task types.
With reference to first aspect, in a kind of possible embodiment, the above method further include:
Set the corresponding one group of semaphore of above-mentioned each child resource thread pool, wherein any child resource thread pool is corresponding
A semaphore is used to indicate in any of the above-described child resource thread pool for executing a kind of appointing for task type in one group of semaphore
The thread resources quantity of business;
It is empty when inquiring thread resources quantity indicated by corresponding first semaphore of above-mentioned target child resource thread pool
When, it determines in above-mentioned target child resource thread pool not for executing the idle thread resource of above-mentioned goal task;
Wherein, above-mentioned first semaphore is used to indicate in above-mentioned target child resource thread pool for executing first task type
Task thread resources quantity, include above-mentioned goal task in the task of above-mentioned first task type.
With reference to first aspect, above-mentioned to be used in above-mentioned target child resource thread pool in a kind of possible embodiment
The thread resources progress thread resources for executing other tasks, which are redistributed, includes:
Above-mentioned first semaphore is modified to increase thread resources quantity indicated by above-mentioned first semaphore;
Modify removed except above-mentioned first semaphore in the corresponding one group of semaphore of above-mentioned target child resource thread pool
Binary signal amount is to reduce thread resources quantity indicated by above-mentioned second signal amount;
Wherein, above-mentioned second signal amount is used to indicate in above-mentioned target child resource thread pool for executing the second task type
Task thread resources quantity, the task of above-mentioned second task type includes other above-mentioned tasks.
Second aspect, the embodiment of the present application provide a kind of thread resources assigned unit, which includes:
Receiving unit determines that the task processing is asked for receiving the task processing request of target service triggering
Ask the task identification and task priority of the goal task of processing;
Matching unit, for determining that the task priority of the goal task is the first priority in the receiving unit
When, target child resource thread pool corresponding with the goal task is determined according to the task identification;
Allocation unit, in the target child resource thread pool not for executing the idle line of the goal task
When Cheng Ziyuan, the thread resources for being used to execute other tasks in target child resource thread pool progress thread resources are divided again
It is equipped with the subject thread resource obtained for executing the goal task, the task priority of other tasks further includes second
Priority, the processing of the processing sequence of the corresponding task of first priority prior to the corresponding task of second priority
Sequentially;
Execution unit, the subject thread resource for being redistributed based on the allocation unit are executed the target and appointed
Business.
In conjunction with second aspect, in a kind of possible embodiment, above-mentioned apparatus further include:
Division unit, for will include that the resource thread pools of multiple thread resources is divided into multiple child resource thread pools,
In, include at least one thread resources in a child resource thread pool, is included at least in above-mentioned multiple child resource thread pools above-mentioned
Target child resource thread pool;
Division unit is also used to set the thread pool mark of each child resource thread pool in above-mentioned multiple child resource thread pools
Know;
Wherein, the thread pool of any child resource thread pool is identified for determining the thread in any of the above-described child resource thread pool
Task of the resource for execution.
In conjunction with second aspect, in a kind of possible embodiment, above-mentioned matching unit is specifically used for from above-mentioned each height
The corresponding subject thread pond mark of above-mentioned task identification is determined in the thread pool mark of resource thread pool, by above-mentioned subject thread
Pond identifies corresponding child resource thread pool and is determined as target child resource thread pool corresponding with above-mentioned goal task.
In conjunction with second aspect, in a kind of possible embodiment, above-mentioned apparatus further include:
Acquiring unit, for obtaining at least two task types, same task type in above-mentioned at least two task type
Task marked by same task identification;
It is preferential to be also used to set the corresponding task of various task types in above-mentioned at least two task type for acquiring unit
Grade, above-mentioned first priority and above-mentioned second priority, above-mentioned various task types pair are included at least in above-mentioned task priority
The task priority answered is used to determine the processing sequence of the task of above-mentioned various task types.
In conjunction with second aspect, in a kind of possible embodiment, above-mentioned allocation unit is specifically used for:
Set the corresponding one group of semaphore of above-mentioned each child resource thread pool, wherein any child resource thread pool is corresponding
A semaphore is used to indicate in any of the above-described child resource thread pool for executing a kind of appointing for task type in one group of semaphore
The thread resources quantity of business;
It is empty when inquiring thread resources quantity indicated by corresponding first semaphore of above-mentioned target child resource thread pool
When, it determines in above-mentioned target child resource thread pool not for executing the idle thread resource of above-mentioned goal task;
Wherein, above-mentioned first semaphore is used to indicate in above-mentioned target child resource thread pool for executing first task type
Task thread resources quantity, include above-mentioned goal task in the task of above-mentioned first task type.
In conjunction with second aspect, in a kind of possible embodiment, above-mentioned allocation unit is specifically used for:
Above-mentioned first semaphore is modified to increase thread resources quantity indicated by above-mentioned first semaphore;
Modify removed except above-mentioned first semaphore in the corresponding one group of semaphore of above-mentioned target child resource thread pool
Binary signal amount is to reduce thread resources quantity indicated by above-mentioned second signal amount;
Wherein, above-mentioned second signal amount is used to indicate in above-mentioned target child resource thread pool for executing the second task type
Task thread resources quantity, the task of above-mentioned second task type includes other above-mentioned tasks.
The third aspect, the embodiment of the present application provide a kind of terminal device, which includes processor and memory,
The processor and memory are connected with each other.The memory for store support the terminal device execute above-mentioned first aspect and/or
The computer program for the method that any possible implementation of first aspect provides, which includes program instruction,
The processor is configured for calling above procedure instruction, executes above-mentioned first aspect and/or first aspect is any possible
Method provided by embodiment.
Fourth aspect, the embodiment of the present application provide a kind of computer readable storage medium, the computer-readable storage medium
Matter is stored with computer program, which includes program instruction, which makes at this when being executed by a processor
It manages device and executes method provided by above-mentioned first aspect and/or any possible embodiment of first aspect.
Implement the embodiment of the present application, has the following beneficial effects:
Method provided by the embodiments of the present application, which can monitor, distributes to the thread resources for executing the task that each business is triggered
Then service condition can realize the inclination to important service when redistributing thread resources, and can provide in real time to thread
Flexibly adjustment is done in source, and applicability is high.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of application for those of ordinary skill in the art without creative efforts, can be with
It obtains other drawings based on these drawings.
Fig. 1 is one flow diagram of method of thread resources distribution provided by the embodiments of the present application;
Fig. 2 is another flow diagram of the method for thread resources distribution provided by the embodiments of the present application;
Fig. 3 is the structural schematic diagram of thread resources assigned unit provided by the embodiments of the present application;
Fig. 4 is the structural schematic diagram of terminal device provided by the embodiments of the present application.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of embodiments of the present application, instead of all the embodiments.It is based on
Embodiment in the application, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall in the protection scope of this application.
The method and device of thread resources provided by the embodiments of the present application distribution, be applicable to smart phone, desktop computer,
The terminal devices such as laptop, tablet computer and wearable device can specifically determine, herein not according to practical application scene
It is limited.For convenience of description, the embodiment of the present application will be illustrated by taking terminal device as an example.
What the method for thread resources provided by the embodiments of the present application distribution was widely portable to that various operational lines handle is
System, the target service that user needs to handle by the business operation interface selection of client, server-side are receiving above-mentioned user institute
After the task processing request that the target service to be handled is triggered, by parsing the critical field institute in above-mentioned task processing request
The information of carrying can determine that the task identification and task priority of goal task.Then, the task mark by having had built up
Know the corresponding relationship between the thread pool of child resource thread pool mark, determines the target for being responsible for executing above-mentioned goal task
Resource thread pool.When there is the idle thread resource for executing above-mentioned goal task in above-mentioned target child resource thread pool, then
Directly above-mentioned goal task is executed using idle thread resource;When above-mentioned not for executing in above-mentioned target child resource thread pool
When the idle thread resource of goal task and above-mentioned goal task belong to the task of the first priority of important service triggering, then exist
The operation that execution thread resource is redistributed in target child resource thread pool provides a part of thread for being used to execute other tasks
Source, which is distributed to, executes above-mentioned goal task use.Method provided by the embodiments of the present application can monitor to distribute to and execute each business and be touched
The service condition of the thread resources of the task of hair, and can realize when redistributing thread resources the inclination to important service,
And flexibly adjustment can be done to thread resources in real time, applicability is high.
Method and device provided by the embodiments of the present application is described in detail respectively below with reference to Fig. 1 to Fig. 4.This Shen
Please embodiment provide method in can be used for include the division of thread pool, the acquisition of task type, task processing request reception,
At the data such as the execution of the determination of the corresponding target child resource thread pool of goal task, the distribution of thread resources and goal task
The reason stage.Wherein, the implementation of above-mentioned each data processing stage can be found in following Fig. 1 to implementation shown in Fig. 2.
Referring to Fig. 1, Fig. 1 is a flow diagram of the method for thread resources provided by the embodiments of the present application distribution.Such as Fig. 1
Shown, method provided by the embodiments of the present application may include steps of:
S1, the receiving target service triggering of the task handle request, determine that the mesh of processing is requested in above-mentioned task processing
The task identification and task priority of mark task.
In some possible embodiments, multi-thread concurrent is common in including web server and/or other are various dedicated
It include all kinds of in the application scenarios of the backstage multi-task parallel processing of server, such as in common multi-thread concurrent application scenarios
The application scenarios of the backstage multi-task parallel processing of server, such as timing sends mail to the user of a large amount of (100w or more), more
Task asynchronous process, data distribution formula calculating of multitask etc..
In some possible embodiments, terminal device receives the task processing triggered when user's transacting business and asks
It asks, wherein above-mentioned task processing request includes processing task and critical field.Under normal conditions, user is by utilizing terminal
That installs in equipment issues task processing request to server using class software.Wherein, include but is not limited to using class software
Instant messaging class software, shopping class software, searching class software, mailbox client, amusement and recreation class software etc., specifically can be according to reality
Border application scenarios are determining, herein with no restrictions.Above-mentioned task identification is used for uniquely tagged task type, and above-mentioned task type can be with
Including calculation type task, communication type task, inquiry type task, search type task dispatching, can specifically be determined according to practical application scene,
Herein with no restrictions.Above-mentioned task identification can be from the feature of task type or execute the pass extracted in the algorithm of task
The key characters either character without Special Significance.Wherein, above-mentioned task type also corresponds to task priority, above-mentioned task priority
In include at least the first priority and the second priority, the task priorities of various task types is for determining above-mentioned various tasks
The processing sequence of the processing sequence of the corresponding task of type, the corresponding task of above-mentioned first priority is preferential prior to above-mentioned second
The processing sequence of the corresponding task of grade.For example, it is assumed that only there are two types of task types, when task is that important service or timeliness are wanted
When task of high business being asked to trigger, the task priority of above-mentioned task is set as the first priority;When above-mentioned task is not weight
When wanting business or the task of the demanding business triggering of timeliness, the task priority for setting above-mentioned task is preferential as second
Grade.After receiving the task processing request of above-mentioned target service triggering, server can be obtained by parsing above-mentioned task processing request
It is entrained about the task identification of goal task and the information of task priority in the critical field in task processing request,
Then the task identification and task priority of above-mentioned goal task be can determine by obtained above- mentioned information.
Appoint as an example it is assumed that user has issued a voice communication by instant messaging class software a certain on terminal device
Business processing request, above-mentioned voice communication task processing request includes voice communication task and critical field, wherein voice communication is appointed
Business is goal task.After server receives the processing request of above-mentioned voice communication task, then to above-mentioned voice communication task at
Reason request is parsed, and can be obtained in the processing request of voice communication task entrained about voice communication task in critical field
Task identification and task priority information, according to obtained above- mentioned information determine voice communication task task identification and appoint
Business priority respectively " communicates " and " the first priority ".
If the task priority of S2, above-mentioned goal task are the first priority, according to above-mentioned task identification it is determining with it is upper
State the corresponding target child resource thread pool of goal task.
In some possible embodiments, the resource thread pool comprising N number of thread resources is divided according to business demand
At n child resource thread pool and set each child resource thread pool thread pool mark, wherein above-mentioned n child resource thread pool
In 1 thread resources is included at least in each child resource thread pool, thread resources are for executing received task.It is understood that
, in order to facilitate the unified management of resource, task identification and thread pool mark between existence anduniquess determine corresponding relationship and
This corresponding relationship is to correspond.That is a task identification can only correspond to a thread pool mark, which can pass through
Mark between task identification and thread pool mark is matched and is established.Then, after receiving goal task, according to goal task
Task identification can find the thread for meeting mark matching relationship with the task identification of goal task from n thread pool mark
Pond mark, and the corresponding child resource thread pool of the thread pool for meeting matching relationship mark is determined as and above-mentioned goal task pair
The target child resource thread pool answered.
If not for executing the idle thread resource of above-mentioned goal task in S3, above-mentioned target child resource thread pool,
The thread resources for being used to execute other tasks in above-mentioned target child resource thread pool progress thread resources are redistributed to obtain
For executing the subject thread resource of above-mentioned goal task.
It in some possible embodiments, can be by looking into after above-mentioned goal task enters target child resource thread pool
It askes and determines whether there is the available idle thread resource for being used to execute above-mentioned goal task in target child resource thread pool.It can be with
Understand, when inquiring the available idle thread resource for being used to execute above-mentioned goal task, then utilizes idle line
Cheng Ziyuan executes above-mentioned goal task;And it is no available for executing the idle thread resource of above-mentioned goal task when inquiring
When, i.e., the thread resources for executing above-mentioned goal task then carry out the weight of thread resources when being fully occupied at current time
New distribution.When thread resources are redistributed, the thread of other tasks is reduced by a certain percentage in target child resource thread pool
Resource uses number, increases the use number for being responsible for the subject thread resource of performance objective task.
S4, above-mentioned goal task is executed based on above-mentioned subject thread resource.
In some possible embodiments, it after redistributing thread resources, is executed based on above-mentioned subject thread resource
Above-mentioned goal task.Since one mission thread of starting can occupy certain thread resources, in order to avoid the waste of resource,
After goal task executes, by the thread resources of release busy, the recycling to resource, recovered thread resources are completed
Wait use next time in thread pool.
In the embodiment of the present application, user passes through the application class software installed on terminal device first and appoints to server sending
Business processing request, server are asked after receiving the task processing request that target service is triggered by parsing above-mentioned task processing
It asks, the information about task identification and task priority entrained in the critical field in task processing request can be obtained, lead to
The above- mentioned information crossed can determine the task identification and task priority of goal task.Then, pass through task identification and line
Mark matching relationship between Cheng Chi mark finds out thread pool mark corresponding with the task identification of above-mentioned goal task, and will be upper
It states the corresponding child resource thread pool of thread pool mark and is determined as target child resource thread pool corresponding with above-mentioned goal task.On if
The task priority for stating goal task is the first priority, when inquiring in above-mentioned target child resource thread pool not for executing
When the idle thread resource of above-mentioned goal task, then execution thread resource is redistributed in target child resource thread pool behaviour
Make, a part of thread resources for being used to execute other tasks are distributed to and execute above-mentioned goal task use and final performance objective
Task.Method provided by the embodiments of the present application can monitor the use for distributing to the thread resources for executing the task that each business is triggered
Situation, and can realize when redistributing thread resources the inclination to important service, and can do in real time to thread resources
Flexibly adjustment, applicability are high.
Fig. 2 is another flow diagram of the method for the thread resources distribution that embodiments herein provides, such as Fig. 2 institute
Show, method provided by the embodiments of the present application may include steps of:
S21, the resource thread pool comprising multiple thread resources is divided into multiple child resource thread pools, and set above-mentioned more
The thread pool mark of each child resource thread pool in a child resource thread pool.
In some possible embodiments, due to as much as possible by a certain the same or similar business or with similar
The task that the business of process flow is triggered, which is divided in, executes the maximum utilization that can be realized resource in a child resource thread pool
The centralized management of rate and resource, therefore according to service parameter, the resource thread pool comprising N number of thread resources can be divided into n
A child resource thread pool, above-mentioned service parameter include but is not limited to type of service or business processing flow or execute algorithm,
It can specifically be determined according to practical application scene, herein with no restrictions.It wherein, include above-mentioned mesh in above-mentioned n child resource thread pool
It marks each child resource thread pool in child resource thread pool and n child resource thread pool and includes at least 1 thread resources.Then it sets
The thread pool mark of each child resource thread pool in above-mentioned n child resource thread pool, wherein thread pool mark can be from above-mentioned
Be responsible in the feature or algorithm of a series of tasks executed in each child resource thread pool the key character that extracts or
It is the character of no Special Significance, and thread pool mark is for uniquely distinguishing the child resource thread pool for being responsible for processing different task.Example
Such as, thread pool mark can be key character " calculating ", " communication ", " inquiry ", " search " the either character without Special Significance
“a”、“b”、“c”、“d”。
S22, at least two task types are obtained, and it is corresponding to set various task types in above-mentioned at least two task type
Task priority.
In some possible embodiments, at least two task types are obtained from assignment database, above-mentioned at least two
The task of same task type is marked by same task identification in kind task type.For example, task type may include calculation type
Task, communication type task, inquiry type task, search type task dispatching.Wherein, task identification can be from the feature of task type or
The key character either character without Special Significance extracted in the algorithm of person's execution task.For example, task identification can be
The key character " calculating " that extracts from above-mentioned task type, " communication ", " inquiry ", " search " are either without Special Significance
Character " 1 ", " 2 ", " 3 ", " 4 ".
Wherein, the corresponding task priority of various task types in above-mentioned at least two task type, above-mentioned task are set
Include at least the first priority and the second priority in priority, the corresponding task priority of above-mentioned various task types is for true
The processing sequence of the task of fixed above-mentioned various task types.Wherein, the processing sequence of the corresponding task of above-mentioned first priority is excellent
The processing sequence of task corresponding prior to above-mentioned second priority.As an example it is assumed that being communication respectively there are two types of task type
Type task and inquiry type task, wherein in instant communication class software, communication type task is all to belong to timeliness under normal conditions
Demanding task or importance task, and inquiry type task is then not belonging to the demanding task of timeliness or importance task,
Therefore when setting task priority, the first priority is set by above-mentioned communication type task, inquiry type task is set as second
Priority.Again for example, in search type engine, inquiry type task is all to belong to timeliness demanding under normal conditions
Business or importance task, and communication type task is then not belonging to the demanding task of timeliness or importance task, therefore is setting
When task priority, the first priority is set by above-mentioned inquiry type task, communication type task is set as the second priority.Work as clothes
It, can preferential answering the when business device receives the task processing request of the task of the first priority and the task of the second priority simultaneously
The processing of one priority tasks is requested, at this point, can lie over the second priority tasks in caching library, subsequent timing is opened
It is dynamic.
S23, the receiving target service triggering of the task handle request, determine that the mesh of processing is requested in above-mentioned task processing
The task identification and task priority of mark task.
In some possible embodiments, terminal device receives the task processing triggered when user's transacting business and asks
It asks, wherein above-mentioned task processing request includes processing task and critical field.Under normal conditions, user is by utilizing terminal
That installs in equipment issues task processing request to server using class software.In the receiving above-mentioned target service triggering of the task
After processing request, institute in the critical field in task processing request is can be obtained by parsing above-mentioned task processing request in server
Carry about the task identification of goal task and the information of task priority, then can determine by obtained above- mentioned information
The task identification and task priority of above-mentioned goal task.
Appoint as an example it is assumed that user has issued a voice communication by instant messaging class software a certain on terminal device
Business processing request, above-mentioned voice communication task processing request includes voice communication task and critical field, wherein voice communication is appointed
Business is goal task.After server receives the processing request of above-mentioned voice communication task, then to above-mentioned voice communication task at
Reason request is parsed, and can be obtained in the processing request of voice communication task entrained about voice communication task in critical field
Task identification and task priority information, according to obtained above- mentioned information determine voice communication task task identification and appoint
Business priority respectively " communicates " and " the first priority ".
If the task priority of S24, above-mentioned goal task are the first priority, according to above-mentioned task identification and above-mentioned line
Corresponding relationship between Cheng Chi mark determines target child resource thread pool corresponding with above-mentioned goal task.
In some possible embodiments, when the feature or calculation that above-mentioned task identification and thread pool mark are from task
When the key character extracted in method, after receiving above-mentioned goal task, in order to determine mesh corresponding with above-mentioned goal task
Mark child resource thread pool, need to traverse all thread pool marks, then by the thread pool mark that will traverse with
The task identification of goal task is identified matching, finally that the thread pool mark of successful match is corresponding child resource thread pool
It is determined as target child resource thread pool corresponding to goal task.
As an example it is assumed that in instant communication class software only have two kinds of task, be respectively inquiry type task and
Communication type task, and the task of above two type will be individually placed to execute in two child resource thread pools.According to the spy of task
Sign or algorithm extract key character " inquiry " and " communication " respectively as the task of above-mentioned inquiry type task and communication type task
Mark.Correspondingly, the thread pool mark that will be responsible for handling the child resource thread pool of these two types of tasks is also respectively set to " inquire "
" communication ".Then, after receiving a new communication task, it can traverse to obtain all thread pool marks and have respectively and " look into
Ask " and " communication ", the thread pool mark then obtained respectively with traversal using the task identification " communication " of above-mentioned new communication task
Know " inquiry " and " communication " to be matched.It is understood that when above-mentioned new communication task task identification " communication " and time
When the thread pool mark " inquiry " gone through is matched, by it fails to match;When the task identification of above-mentioned new communication task is " logical
When letter " is matched with the thread pool mark " communication " traversed, successful match is then referred to thread pool mark " communication "
Child resource thread pool be determined as the target child resource thread pool of above-mentioned new communication task.
Optionally, in some possible embodiments, it is possible to be responsible for a series of tasks executed for child resource thread pool
There is no similar feature.Therefore, when above-mentioned task identification and thread pool mark be the character of no Special Significance when, in order to determine with
The corresponding target child resource thread pool of goal task needs to establish the mapping table an of task identification and thread pool mark in advance,
Then it after receiving goal task, is found out and is corresponding to it with this according to the above-mentioned mapping table of the task identification of above-mentioned goal task lookup
Thread pool mark, finally by above-mentioned thread pool identify corresponding child resource thread pool be determined as it is corresponding with above-mentioned goal task
Target child resource thread pool.
As an example it is assumed that the task there are three types of type is Class1, type 2, type 3, and above-mentioned three types respectively
Task will be individually placed to execute in three child resource thread pools.Then, the task identification of the task of these three types is set respectively
1,2,3 are set to, the thread pool mark that will be responsible for the child resource thread pool for the executing these three types of the task is respectively set to a, b,
A mapping table is arranged for the relationship established between task identification and thread pool mark in c, in the mapping table, thread pool mark
A corresponds to task identification 1, and thread pool mark b corresponds to task identification 2, and thread pool mark c corresponds to task identification 3.Wherein, either
Thread pool mark or task identification, contribute to unique identification child resource thread pool and task type.Then, when receiving
When one new the belonging to Class1 of the task, the mapping table of above-mentioned foundation is inquired according to the task identification 1 of Class1, can be found and be appointed
The corresponding thread pool of business mark 1 identifies a, so that it is determined that the child resource thread pool that thread pool mark a is referred to is that above-mentioned task is
The target child resource thread pool of the task of Class1.
S25, the corresponding one group of semaphore of above-mentioned each child resource thread pool is set, in target child resource thread pool, when
The quantity of subject thread resource indicated by the corresponding semaphore of task type corresponding to above-mentioned goal task is inquired as sky
When, modify the distribution that each semaphore in above-mentioned target child resource thread pool adjusts above-mentioned subject thread resource with this.
In some possible embodiments, for business demand further abundant, each child resource thread pool is most
The task of processing multiple tasks type will be respectively corresponded in number situation.In order to avoid a certain identical and/or similar tasks type
The task processing request of task occupy a large amount of thread resources in synchronization, so as to cause the task of other task types
In the case where falling into a long wait it can be set separately to above-mentioned n child resource thread pool in task processing request
Corresponding one group of semaphore.Wherein, a semaphore in the corresponding one group of semaphore of any child resource thread pool is used to indicate
For executing a kind of thread resources quantity of the task of task type in any of the above-described child resource thread pool.In target child resource line
Cheng Chizhong, when inquiring subject thread resource indicated by the corresponding semaphore of task type corresponding to above-mentioned goal task
When quantity is empty, determine in above-mentioned target child resource thread pool not for executing the idle thread resource of above-mentioned goal task.
Then, by modifying the corresponding semaphore of task type corresponding to above-mentioned goal task to increase corresponding to above-mentioned goal task
The corresponding semaphore of task type indicated by subject thread resource quantity, it is corresponding to modify above-mentioned target child resource thread pool
One group of semaphore in remove other semaphores except the corresponding semaphore of task type corresponding to above-mentioned goal task with
Reduce the quantity of thread resources indicated by other above-mentioned semaphores.Wherein, other above-mentioned semaphores are used to indicate above-mentioned target
For executing the quantity of the thread resources of the task of other task types in child resource thread pool.
In some possible embodiments, the mode of above-mentioned modification semaphore include according to modification instruction modify or
Person modifies according to preset adjusting parameter.Wherein, being modified according to modification instruction is to refer in each modification in modification
The adjustment quantity of each semaphore in every group of semaphore is keyed in order, this modification mode is more flexible.According to preset adjustment
It is an adjusting parameter to be preset in machine instruction, for example set 1 for adjusting parameter that parameter, which is modified, then adjusts every time
Signal discharge amplitude is exactly to add 1 in original basis or subtract 1.
For example, in order to make thread resources be utilized effectively, it is assumed that task of will there is safe-on class business to be triggered
It is handled with a child resource thread pool, then, above-mentioned child resource thread pool is target child resource thread pool.Wherein, insure
Including life insurance, property insurance, vehicle insurance, travel accident insurance, etc..It include insurance purchase by the task that different insurance businesses is triggered
It buys, declaration form inquiry, settlement of insurance claim etc..For above-mentioned target child resource thread pool, it is assumed that its maximum concurrent thread number is 15, i.e.,
There are 15 available thread resources, one group of semaphore then can be set and control workable for every class insurance for completing every appoint
The quantity of the thread resources of business.For example setting signal amount 5 is used to indicate 5 Thread Counts for life insurance, setting signal amount 3 is used
It is used for property insurance in 3 Thread Counts of instruction, setting signal amount 4 to be used to indicate 4 Thread Counts for vehicle insurance, setting signal amount 2
2 Thread Counts are used to indicate for travel accident insurance, setting signal amount 1 is used to indicate 1 Thread Count and insures for other classes.It can manage
Solution, when some festivals or holidays come it is interim, the people that holiday period project is travelled outdoors be it is most, at this moment in terms of travel accident insurance
Business handling can be busier than during on weekdays.It therefore, can be by travel accident insurance business shortly before some legal festivals and holidays arrives
The task priority of all tasks triggered is set as the first priority.Then, during before and after festivals or holidays, when receiving
When request is bought in the insurance of one travel accident insurance, inquire as semaphore set by above-mentioned travel accident insurance, when semaphore is not sky, i.e.,
When the current occupancy quantity of thread resources is less than 2 Thread Counts, illustrate have available idle thread for executing the purchase of travelling danger
Request is bought, then executes above-mentioned purchase task using idle thread resources.When inquiring as letter set by above-mentioned travel accident insurance
When number amount is empty, i.e., when the current occupancy quantity of thread resources is equal to 2 Thread Counts, illustrate that no available idle thread is used for
Execute the purchase task requests of travelling danger.Therefore execution thread resource is redistributed, and select to modify the mode of semaphore to be logical
Modification instruction is crossed when modifying, semaphore 4 can be modified and be used to indicate 4 Thread Counts for life insurance, semaphore 3 is modified and use
It is used for property insurance in 3 Thread Counts of instruction, modification semaphore 4 to be used to indicate 4 Thread Counts for vehicle insurance, modifies semaphore 3
3 Thread Counts are used to indicate for travel accident insurance, semaphore 1 is modified and is used to indicate 1 Thread Count for the insurance of other classes.
Optionally, in some possible embodiments, in order to realize the peak use rates of thread resources, for each letter
Number amount be also provided with borrow label, borrow label includes whether need borrow label and whether allow borrow mark.For example, it is desired to
The label of borrow is set as 00, and the label for not needing to borrow is set as 01, allows the label borrowed to be set as 10, does not allow to borrow
Label be set as 11, and if only if borrow side need borrow and by debit allow borrow when, be just able to satisfy borrow condition.Example
Such as, when the semaphore for inquiring above-mentioned goal task is empty, label 00 is borrowed as needed and is mentioned to the semaphore of other tasks
It lends and is borrowed successfully with request when the semaphore of other tasks is unsaturated and allows to borrow (having allows to borrow label 10),
Above-mentioned goal task is executed using the idle thread resource of other tasks borrowed at this time;When the signal for inquiring other tasks
When amount is similarly empty or does not allow to borrow (having not allows to borrow label 11), obstruction is added in above-mentioned goal task and waits team
Column, and an observation signal is set and monitors the obstruction waiting time of above-mentioned goal task or is lined up number, while a resistance is set
Plug waiting time threshold value is perhaps lined up the above-mentioned obstruction waiting time threshold value of number threshold value or queuing number threshold value numerical values recited with open
Originator is related to the performance requirement of server.It is waited when the obstruction waiting time of above-mentioned goal task or queuing number are less than obstruction
When time threshold or queuing number threshold value, then thread resources are discharged after waiting until the task execution for coming front always,
The thread resources of release are recycled to execute above-mentioned goal task;When the obstruction waiting time of above-mentioned goal task or queuing number are big
In or be equal to obstruction waiting time threshold value or be lined up number threshold value but still without idle thread resource when, then execution thread provide
Source is redistributed, and the method for salary distribution is for example above-mentioned, and details are not described herein.
S26, above-mentioned goal task is executed based on above-mentioned subject thread resource.
In some possible embodiments, it after redistributing thread resources, is executed based on above-mentioned subject thread resource
Above-mentioned goal task.Since one mission thread of starting can occupy certain thread resources, in order to avoid the waste of resource,
After goal task executes, by the thread resources of release busy, the recycling to resource, recovered thread resources are completed
Wait use next time in thread pool.
Optionally, in some possible embodiments, the big demand task of certain class may belong to parallel task, i.e., do not deposit
In priority height, in this case, service can be provided by way of increasing machine, i.e. every machine possesses independent
Semaphore configuration is served only for being responsible for executing the big demand task of certain class, for details, reference can be made to the implementation under above-mentioned single machine,
Details are not described herein.
In the embodiment of the present application, it firstly, obtaining at least two task types in assignment database, and sets every kind and appoints
Resource thread pool comprising N number of thread resources has been divided into n child resource line by the task identification and task priority of service type
Cheng Chi and the thread pool mark for setting each child resource thread pool.Wherein, pass through mark between task identification and thread pool mark
Know matching and/or mapping table establishes corresponding relationship.Then user is by the application class software installed on terminal device to server
The processing request of sending task, server is after receiving the task processing request that target service is triggered, by parsing above-mentioned task
Information entrained in the critical field in task processing request can be obtained, to determine by above- mentioned information in processing request
The task identification and task priority of goal task.Recycle the corresponding relationship between the task identification established and thread pool mark
It determines and is responsible for executing the corresponding target child resource thread pool of above-mentioned goal task.In the embodiment of the present application in order to avoid a certain phase
The task processing request of same and/or similar tasks type task occupies a large amount of thread resources in synchronization, a to above-mentioned n
Its corresponding one group of semaphore has been set separately in child resource thread pool.Wherein, the corresponding one group of signal of any child resource thread pool
A semaphore in amount is used to indicate in any of the above-described child resource thread pool for executing a kind of line of the task of task type
Journey resource quantity.In target child resource thread pool, when inquiring the corresponding letter of task type corresponding to above-mentioned goal task
When the quantity of number indicated subject thread resource of amount is empty, then by modification semaphore with thread indicated by adjustment signal amount
Then the quantity of resource executes above-mentioned goal task using the thread resources after redistributing.Side provided by the embodiments of the present application
Method can monitor the service condition for distributing to the thread resources for executing the task that each business is triggered, and redistribute thread money
The inclination to important service can be realized when source, and flexibly adjustment can be done to thread resources in real time, and applicability is high.
Referring to Fig. 3, Fig. 3 is the structural schematic diagram of thread resources assigned unit provided by the present application, the embodiment of the present application
The thread resources assigned unit of offer includes:
Receiving unit 31 determines above-mentioned task processing request institute for receiving the task processing request of target service triggering
Request the task identification and task priority of the goal task of processing;
Matching unit 32, for determining that the task priority of above-mentioned goal task is first preferential in above-mentioned receiving unit 31
When grade, target child resource thread pool corresponding with above-mentioned goal task is determined according to above-mentioned task identification;
Allocation unit 33, in above-mentioned target child resource thread pool not for executing the free time of above-mentioned goal task
When thread resources, the thread resources for being used to execute other tasks in above-mentioned target child resource thread pool are subjected to thread resources again
To obtain the subject thread resource for executing above-mentioned goal task, the task priority of other above-mentioned tasks further includes for distribution
Two priority, the place of the processing sequence of the corresponding task of above-mentioned first priority prior to the corresponding task of above-mentioned second priority
Make sequence in order;
Execution unit 34, the above-mentioned subject thread resource for being redistributed based on above-mentioned allocation unit 33 execute above-mentioned mesh
Mark task.
In some possible embodiments, the thread resources distributor further include:
Division unit 35, for will include that the resource thread pools of multiple thread resources is divided into multiple child resource thread pools,
Wherein, include at least one thread resources in a child resource thread pool, included at least in above-mentioned multiple child resource thread pools upper
State target child resource thread pool;
Division unit 35 is also used to set the thread pool mark of each child resource thread pool in above-mentioned multiple child resource thread pools
Know;
Wherein, the thread pool of any child resource thread pool is identified for determining the thread in any of the above-described child resource thread pool
Task of the resource for execution.
In some possible embodiments, above-mentioned matching unit 32 is used for:
The corresponding subject thread of above-mentioned task identification is determined from the thread pool of above-mentioned each child resource thread pool mark
Above-mentioned subject thread pond is identified corresponding child resource thread pool and is determined as target corresponding with above-mentioned goal task by pond mark
Resource thread pool.
In some possible embodiments, the thread resources distributor further include:
Acquiring unit 36, for obtaining at least two task types, same task class in above-mentioned at least two task type
The task of type is marked by same task identification;
It is preferential to be also used to set the corresponding task of various task types in above-mentioned at least two task type for acquiring unit 36
Grade, above-mentioned first priority and above-mentioned second priority, above-mentioned various task types pair are included at least in above-mentioned task priority
The task priority answered is used to determine the processing sequence of the task of above-mentioned various task types.
In some possible embodiments, above-mentioned allocation unit 33 is used for:
Set the corresponding one group of semaphore of above-mentioned each child resource thread pool, wherein any child resource thread pool is corresponding
A semaphore is used to indicate in any of the above-described child resource thread pool for executing a kind of appointing for task type in one group of semaphore
The thread resources quantity of business;
It is empty when inquiring thread resources quantity indicated by corresponding first semaphore of above-mentioned target child resource thread pool
When, it determines in above-mentioned target child resource thread pool not for executing the idle thread resource of above-mentioned goal task;
Wherein, above-mentioned first semaphore is used to indicate in above-mentioned target child resource thread pool for executing first task type
Task thread resources quantity, include above-mentioned goal task in the task of above-mentioned first task type.
In some possible embodiments, above-mentioned allocation unit 33 is used for:
Above-mentioned first semaphore is modified to increase thread resources quantity indicated by above-mentioned first semaphore;
Modify removed except above-mentioned first semaphore in the corresponding one group of semaphore of above-mentioned target child resource thread pool
Binary signal amount is to reduce thread resources quantity indicated by above-mentioned second signal amount;
Wherein, above-mentioned second signal amount is used to indicate in above-mentioned target child resource thread pool for executing the second task type
Task thread resources quantity, the task of above-mentioned second task type includes other above-mentioned tasks.
In the specific implementation, above-mentioned thread resources assigned unit can be executed by each functional module built in it as above-mentioned
Fig. 1 implementation provided by each step into Fig. 2.For example, above-mentioned receiving unit 31 can be used for executing above-mentioned each step
Middle the receiving target service triggering of the task handles request, and determines that the goal task of processing is requested in above-mentioned task processing
Task identification and task priority, for details, reference can be made to implementations provided by above-mentioned each step, and details are not described herein.On
State matching unit 32 can be used for executing in above-mentioned each step according to above-mentioned task identification determination it is corresponding with above-mentioned goal task
Implementation described in the correlation step of target child resource thread pool, for details, reference can be made to realize provided by above-mentioned each step
Mode, details are not described herein.Above-mentioned allocation unit 33, which can be used for executing, sets above-mentioned each child resource line in above-mentioned each step
Thread resources indicated by the corresponding one group of semaphore of Cheng Chi, corresponding first semaphore of the above-mentioned target child resource thread pool of inquiry
Quantity, above-mentioned first semaphore of modification are to increase thread resources quantity indicated by above-mentioned first semaphore and other implementations, tool
Body can be found in implementation provided by above-mentioned each step, and details are not described herein.Above-mentioned execution unit 34 can be used in execution
State the phase for executing above-mentioned goal task in each step based on the above-mentioned subject thread resource that above-mentioned allocation unit 33 is redistributed
Implementation described in step is closed, for details, reference can be made to implementations provided by above-mentioned each step, and details are not described herein.On
Stating division unit 35 can be used for executing the realizations side such as the division of thread pool and the setting of thread pool mark in above-mentioned each embodiment
Formula, for details, reference can be made to implementations provided by above-mentioned each embodiment, and details are not described herein.Above-mentioned acquiring unit 36 can be used for
Execute the task identification that task type and the above-mentioned task type of setting are obtained in above-mentioned each embodiment and task priority etc.
Implementation, for details, reference can be made to implementations provided by above-mentioned each embodiment, and details are not described herein.
In the embodiment of the present application, thread resources assigned unit can task based access control database at least two task class of acquisition
Type, and then the task identification and task priority of any task type are set, and will include N number of thread resources based on service parameter
Resource thread pool be divided into n child resource thread pool, set each child resource thread pool in above-mentioned n child resource thread pool
Thread pool mark establishes the corresponding relationship between task identification and thread pool mark.At the receiving target service triggering of the task
When reason request, in task based access control processing request in critical field in entrained information determine goal task task identification and
Priority finds target child resource from n child resource thread pool according to the matching relationship between task identification and thread identification
Thread pool, and by above-mentioned target child resource thread pool to the request for information of the thread resources of responsible performance objective task,
Thread resources in target child resource thread pool are redistributed, and final performance objective task.The embodiment of the present application mentions
The device of confession can monitor the service condition for distributing to the thread resources for executing the task that each business is triggered, and redistribute
The inclination to important service can be realized when thread resources, and flexibly adjustment, the scope of application can be done to thread resources in real time
Extensively.
Referring to fig. 4, Fig. 4 is the structural schematic diagram of terminal device provided by the embodiments of the present application.As shown in figure 4, this implementation
Terminal device in example may include: one or more processors 401 and memory 402.Above-mentioned processor 401 and memory
402 are connected by bus 403.For memory 402 for storing computer program, which includes program instruction, processing
Device 401 is used to execute the program instruction of the storage of memory 402, performs the following operations:
The receiving target service triggering of the task handles request, determines that above-mentioned task processing requests the target of processing to be appointed
The task identification and task priority of business;
If the task priority of above-mentioned goal task is the first priority, according to the determination of above-mentioned task identification and above-mentioned mesh
The corresponding target child resource thread pool of mark task;
If, will be upper not for executing the idle thread resource of above-mentioned goal task in above-mentioned target child resource thread pool
It states in target child resource thread pool and redistributes for executing the thread resources progress thread resources of other tasks to obtain and be used for
The subject thread resource of above-mentioned goal task is executed, the task priority of other above-mentioned tasks further includes the second priority, above-mentioned
Processing sequence of the processing sequence of the corresponding task of first priority prior to the corresponding task of above-mentioned second priority;
Above-mentioned goal task is executed based on above-mentioned subject thread resource.
In some possible embodiments, above-mentioned processor 401 is used for:
Resource thread pool comprising multiple thread resources is divided into multiple child resource thread pools, wherein a child resource
Include at least one thread resources in thread pool, includes at least above-mentioned target child resource thread in above-mentioned multiple child resource thread pools
Pond;
Set the thread pool mark of each child resource thread pool in above-mentioned multiple child resource thread pools;
Wherein, the thread pool of any child resource thread pool is identified for determining the thread in any of the above-described child resource thread pool
Task of the resource for execution.
In some possible embodiments, above-mentioned processor 401 is used for:
The corresponding subject thread of above-mentioned task identification is determined from the thread pool of above-mentioned each child resource thread pool mark
Above-mentioned subject thread pond is identified corresponding child resource thread pool and is determined as target corresponding with above-mentioned goal task by pond mark
Resource thread pool.
In some possible embodiments, above-mentioned processor 401 is used for:
At least two task types are obtained, the task of same task type is by same in above-mentioned at least two task type
Business mark label;
Set the corresponding task priority of various task types in above-mentioned at least two task type, above-mentioned task priority
In include at least above-mentioned first priority and above-mentioned second priority, the corresponding task priority of above-mentioned various task types is used for
Determine the processing sequence of the task of above-mentioned various task types.
In some possible embodiments, above-mentioned processor 401 is used for:
Set the corresponding one group of semaphore of above-mentioned each child resource thread pool, wherein any child resource thread pool is corresponding
A semaphore is used to indicate in any of the above-described child resource thread pool for executing a kind of appointing for task type in one group of semaphore
The thread resources quantity of business;
It is empty when inquiring thread resources quantity indicated by corresponding first semaphore of above-mentioned target child resource thread pool
When, it determines in above-mentioned target child resource thread pool not for executing the idle thread resource of above-mentioned goal task;
Wherein, above-mentioned first semaphore is used to indicate in above-mentioned target child resource thread pool for executing first task type
Task thread resources quantity, include above-mentioned goal task in the task of above-mentioned first task type.
In some possible embodiments, above-mentioned processor 401 is used for:
Above-mentioned first semaphore is modified to increase thread resources quantity indicated by above-mentioned first semaphore;
Modify removed except above-mentioned first semaphore in the corresponding one group of semaphore of above-mentioned target child resource thread pool
Binary signal amount is to reduce thread resources quantity indicated by above-mentioned second signal amount;
Wherein, above-mentioned second signal amount is used to indicate in above-mentioned target child resource thread pool for executing the second task type
Task thread resources quantity, the task of above-mentioned second task type includes other above-mentioned tasks.
It should be appreciated that in some possible embodiments, above-mentioned processor 401 can be central processing unit
(central processing unit, CPU), which can also be other general processors, digital signal processor
(digital signal processor, DSP), specific integrated circuit (application specific integrated
Circuit, ASIC), ready-made programmable gate array (field programmable gate array, FPGA) or other can
Programmed logic device, discrete gate or transistor logic, discrete hardware components etc..General processor can be microprocessor
Or the processor is also possible to any conventional processor etc..The memory 402 may include read-only memory and deposit at random
Access to memory, and instruction and data is provided to processor 401.The a part of of memory 402 can also include non-volatile random
Access memory.For example, memory 402 can be with the information of storage device type.
In the specific implementation, above-mentioned terminal device can be executed by each functional module built in it if above-mentioned Fig. 1 is into Fig. 2
Implementation provided by each step, for details, reference can be made to implementations provided by above-mentioned each step, and details are not described herein.
In the embodiment of the present application, terminal device can task based access control database obtain at least two task types, Jin Ershe
The task identification and task priority of fixed any task type, and based on service parameter by the resource line comprising N number of thread resources
Cheng Chi is divided into n child resource thread pool, sets the thread pool mark of each child resource thread pool in above-mentioned n child resource thread pool
Know, establishes the corresponding relationship between task identification and thread pool mark.When the receiving target service triggering of the task handles request,
Entrained information determines the task identification and priority of goal task, root in critical field in task based access control processing request
Target child resource thread pool is found from n child resource thread pool according to the matching relationship between task identification and thread identification, and
By, to the request for information of the thread resources of responsible performance objective task, being provided to target in above-mentioned target child resource thread pool
Thread resources in the thread pool of source are redistributed, and final performance objective task.Device provided by the embodiments of the present application can
The service condition for executing the thread resources for the task that each business is triggered is distributed in monitoring, and when redistributing thread resources
The inclination to important service can be achieved, and thread resources can be adjusted flexibly in real time, it is applied widely.
The embodiment of the present application also provides a kind of computer readable storage medium, which has meter
Calculation machine program, the computer program include program instruction, which realizes that Fig. 1 is each into Fig. 2 when being executed by processor
The method of the distribution of thread resources provided by step, for details, reference can be made to implementations provided by above-mentioned each step, herein not
It repeats again.
Above-mentioned computer readable storage medium can be the thread resources distributor that aforementioned any embodiment provides or
The internal storage unit of above-mentioned terminal device, such as the hard disk or memory of electronic equipment.The computer readable storage medium can also
To be the plug-in type hard disk being equipped on the External memory equipment of the electronic equipment, such as the electronic equipment, intelligent memory card
(smart media card, SMC), secure digital (secure digital, SD) card, flash card (flash card) etc..Into
One step, the computer readable storage medium can also both internal storage units including the electronic equipment or including external storage
Equipment.The computer readable storage medium is for storing other program sum numbers needed for the computer program and the electronic equipment
According to.The computer readable storage medium can be also used for temporarily storing the data that has exported or will export.
Following claims and term " first " in specification and attached drawing, " second ", " third ", " the 4th " etc.
It is to be not use to describe a particular order for distinguishing different objects.In addition, term " includes " and " having " and they are any
Deformation, it is intended that cover and non-exclusive include.Such as contain the process, method, system, product of a series of steps or units
Or equipment is not limited to listed step or unit, but optionally further comprising the step of not listing or unit, or can
Selection of land further includes the other step or units intrinsic for these process, methods, product or equipment.It is referenced herein " to implement
Example " is it is meant that a particular feature, structure, or characteristic described may be embodied at least one embodiment of the application in conjunction with the embodiments
In.The term "and/or" used in present specification and the appended claims refers to one in the associated item listed
A or multiple any combination and all possible combinations, and including these combinations.Method provided by the embodiments of the present application and
Relevant apparatus is described referring to method flow diagram provided by the embodiments of the present application and/or structural schematic diagram, specifically can be by counting
The each flow and/or block and flow chart of calculation machine program instruction implementation method flow chart and/or structural schematic diagram and/or
The combination of process and/or box in block diagram.
The above disclosure is only the preferred embodiments of the present invention, cannot limit the right model of the present invention with this certainly
It encloses, therefore equivalent changes made in accordance with the claims of the present invention, is still within the scope of the present invention.
Claims (10)
1. a kind of method of thread resources distribution characterized by comprising
The receiving target service triggering of the task handles request, determines that the goal task of processing is requested in the task processing
Task identification and task priority;
If the task priority of the goal task is the first priority, appoint according to the task identification is determining with the target
It is engaged in corresponding target child resource thread pool;
If not for executing the idle thread resource of the goal task in the target child resource thread pool, by the mesh
It redistributes in mark child resource thread pool for executing the thread resources progress thread resources of other tasks to obtain for executing
The subject thread resource of the goal task, the task priority of other tasks further include the second priority, and described first
Processing sequence of the processing sequence of the corresponding task of priority prior to the corresponding task of second priority;
The goal task is executed based on the subject thread resource.
2. method according to claim 1, which is characterized in that the task processing request for receiving target service triggering
Before, the method also includes:
Resource thread pool comprising multiple thread resources is divided into multiple child resource thread pools, wherein a child resource thread
Include at least one thread resources in pond, includes at least the target child resource thread pool in the multiple child resource thread pool;
Set the thread pool mark of each child resource thread pool in the multiple child resource thread pool;
Wherein, the thread pool of any child resource thread pool is identified for determining the thread resources in any child resource thread pool
Task for execution.
3. method according to claim 2, which is characterized in that described according to task identification determination and the goal task
Corresponding target child resource thread pool includes:
Determine that the corresponding subject thread pond of the task identification is marked from the thread pool of each child resource thread pool mark
Know, the subject thread pond is identified into corresponding child resource thread pool and is determined as target child resource corresponding with the goal task
Thread pool.
4. any one of -3 the method according to claim 1, which is characterized in that the determination task processing is requested
Before the task identification and task priority of the goal task of processing, the method also includes:
At least two task types are obtained, the task of same task type is by same task mark at least two task type
Know label;
Set the corresponding task priority of various task types at least two task type, in the task priority extremely
It less include first priority and second priority, the corresponding task priority of the various task types is for determining
The processing sequence of the task of the various task types.
5. method according to claim 4, which is characterized in that the method also includes:
Set the corresponding one group of semaphore of each child resource thread pool, wherein any child resource thread pool is one group corresponding
A semaphore is used to indicate a kind of being used to execute task type in any child resource thread pool of the task in semaphore
Thread resources quantity;
When it is empty for inquiring thread resources quantity indicated by corresponding first semaphore of the target child resource thread pool, really
Not for executing the idle thread resource of the goal task in the fixed target child resource thread pool;
Wherein, first semaphore is used to indicate in the target child resource thread pool for executing appointing for first task type
The thread resources quantity of business includes the goal task in the task of the first task type.
6. method according to claim 5, which is characterized in that described to be used to execute it in the target child resource thread pool
The thread resources progress thread resources of his task, which are redistributed, includes:
First semaphore is modified to increase thread resources quantity indicated by first semaphore;
Modify the second letter removed except first semaphore in the corresponding one group of semaphore of the target child resource thread pool
Number amount to reduce thread resources quantity indicated by the second signal amount;
Wherein, the second signal amount is used to indicate in the target child resource thread pool for executing appointing for the second task type
The thread resources quantity of business, the task of second task type include other described tasks.
7. a kind of thread resources assigned unit characterized by comprising
Receiving unit determines at task processing request institute's request for receiving the task processing request of target service triggering
The task identification and task priority of the goal task of reason;
Matching unit, when for determining that the task priority of the goal task is the first priority in the receiving unit, root
Target child resource thread pool corresponding with the goal task is determined according to the task identification;
Allocation unit, for not provided for executing the idle thread of the goal task in the target child resource thread pool
When source, by the thread resources for being used to execute other tasks in the target child resource thread pool progress thread resources redistribute with
The subject thread resource for executing the goal task is obtained, the task priority of other tasks further includes second preferential
The processing sequence of grade, the corresponding task of first priority is suitable prior to the processing of the corresponding task of second priority
Sequence;
Execution unit, the subject thread resource for being redistributed based on the allocation unit execute the goal task.
8. device according to claim 7, which is characterized in that described device further include:
Division unit, for will include that the resource thread pools of multiple thread resources is divided into multiple child resource thread pools, wherein one
Include at least one thread resources in a child resource thread pool, target is included at least in the multiple child resource thread pool
Resource thread pool;
Division unit is also used to set the thread pool mark of each child resource thread pool in the multiple child resource thread pool;
Wherein, the thread pool of any child resource thread pool is identified for determining the thread resources in any child resource thread pool
Task for execution.
9. a kind of terminal device, which is characterized in that including processor and memory, the processor and memory are connected with each other;
The memory is for storing computer program, and the computer program includes program instruction, and the processor is configured
For calling described program to instruct, as the method according to claim 1 to 6 is executed.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has computer journey
Sequence, the computer program include program instruction, and described program instruction executes the processor such as
Method described in any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811541874.2A CN109783229A (en) | 2018-12-17 | 2018-12-17 | The method and device of thread resources distribution |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811541874.2A CN109783229A (en) | 2018-12-17 | 2018-12-17 | The method and device of thread resources distribution |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109783229A true CN109783229A (en) | 2019-05-21 |
Family
ID=66497099
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811541874.2A Pending CN109783229A (en) | 2018-12-17 | 2018-12-17 | The method and device of thread resources distribution |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109783229A (en) |
Cited By (24)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110377412A (en) * | 2019-07-24 | 2019-10-25 | 湖南快乐阳光互动娱乐传媒有限公司 | A kind of method for scheduling task and system |
CN110430229A (en) * | 2019-06-19 | 2019-11-08 | 特斯联(北京)科技有限公司 | Intelligence community Internet of Things heat transfer agent acquisition processing system and method based on cloud platform |
CN110781000A (en) * | 2019-10-17 | 2020-02-11 | 中国建设银行股份有限公司 | Multi-application resource allocation method and device |
CN110825732A (en) * | 2019-09-20 | 2020-02-21 | 广州亚美信息科技有限公司 | Data query method and device, computer equipment and readable storage medium |
CN111552567A (en) * | 2020-04-27 | 2020-08-18 | 北京奇艺世纪科技有限公司 | Thread management method and device, electronic equipment and storage medium |
CN111625329A (en) * | 2020-05-18 | 2020-09-04 | 北京达佳互联信息技术有限公司 | Task allocation method and device, electronic equipment, server and storage medium |
CN111651272A (en) * | 2020-05-28 | 2020-09-11 | 苏州大学 | Thread time management method and device for embedded real-time operation |
CN111709723A (en) * | 2020-07-20 | 2020-09-25 | 港胜技术服务(深圳)有限公司 | RPA business process intelligent processing method, device, computer equipment and storage medium |
CN111767125A (en) * | 2020-06-15 | 2020-10-13 | 杭州数梦工场科技有限公司 | Task execution method and device, electronic equipment and storage medium |
CN111782293A (en) * | 2020-06-28 | 2020-10-16 | 珠海豹趣科技有限公司 | Task processing method and device, electronic equipment and readable storage medium |
CN111797074A (en) * | 2020-07-03 | 2020-10-20 | 中国建设银行股份有限公司 | Database connection method and device, electronic equipment and readable storage medium |
CN111813546A (en) * | 2020-06-30 | 2020-10-23 | 济南浪潮数据技术有限公司 | Resource allocation method, system and related device for multi-network connection application |
CN112019454A (en) * | 2019-05-29 | 2020-12-01 | 潘仲光 | Resource processing method, device and storage medium |
CN112099945A (en) * | 2020-08-20 | 2020-12-18 | 深圳市元征科技股份有限公司 | Task processing method, task processing device and electronic equipment |
CN112328634A (en) * | 2020-10-16 | 2021-02-05 | 中国建设银行股份有限公司 | Database-based operation request processing method and device |
CN112395064A (en) * | 2020-11-18 | 2021-02-23 | 中国联合网络通信集团有限公司 | Thread scheduling method and device |
CN112434924A (en) * | 2020-11-18 | 2021-03-02 | 刘凤 | Risk inspection monitoring platform based on cloud platform under full-electric-network multi-source data |
CN112527509A (en) * | 2020-12-21 | 2021-03-19 | 北京百度网讯科技有限公司 | Resource allocation method and device, electronic equipment and storage medium |
CN112689007A (en) * | 2020-12-23 | 2021-04-20 | 江苏苏宁云计算有限公司 | Resource allocation method, device, computer equipment and storage medium |
CN112783659A (en) * | 2021-02-01 | 2021-05-11 | 北京百度网讯科技有限公司 | Resource allocation method and device, computer equipment and storage medium |
CN112948085A (en) * | 2021-03-03 | 2021-06-11 | 杉数科技(北京)有限公司 | Task scheduling processing method and device |
CN113238501A (en) * | 2021-05-08 | 2021-08-10 | 西安联乘智能科技有限公司 | Vehicle networking control method and system based on RTOS operating system |
CN113641476A (en) * | 2021-08-16 | 2021-11-12 | 腾讯科技(深圳)有限公司 | Task scheduling method, game engine, equipment and storage medium |
CN114860814A (en) * | 2022-07-05 | 2022-08-05 | 天津金城银行股份有限公司 | Credit investigation processing system, method, credit investigation system, device and medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102207890A (en) * | 2011-05-27 | 2011-10-05 | 苏州阔地网络科技有限公司 | Task information processing method and scheduling control processing device |
CN102331923A (en) * | 2011-10-13 | 2012-01-25 | 西安电子科技大学 | Multi-core and multi-threading processor-based functional macropipeline implementing method |
US20150058858A1 (en) * | 2013-08-21 | 2015-02-26 | Hasso-Platt ner-Institut fur Softwaresystemtechnik GmbH | Dynamic task prioritization for in-memory databases |
CN104572277A (en) * | 2014-12-17 | 2015-04-29 | 大唐移动通信设备有限公司 | Thread flow control method and thread flow control device |
CN107305548A (en) * | 2016-04-18 | 2017-10-31 | 北京国双科技有限公司 | Control the method for allocating tasks and device of web crawlers |
-
2018
- 2018-12-17 CN CN201811541874.2A patent/CN109783229A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102207890A (en) * | 2011-05-27 | 2011-10-05 | 苏州阔地网络科技有限公司 | Task information processing method and scheduling control processing device |
CN102331923A (en) * | 2011-10-13 | 2012-01-25 | 西安电子科技大学 | Multi-core and multi-threading processor-based functional macropipeline implementing method |
US20150058858A1 (en) * | 2013-08-21 | 2015-02-26 | Hasso-Platt ner-Institut fur Softwaresystemtechnik GmbH | Dynamic task prioritization for in-memory databases |
CN104572277A (en) * | 2014-12-17 | 2015-04-29 | 大唐移动通信设备有限公司 | Thread flow control method and thread flow control device |
CN107305548A (en) * | 2016-04-18 | 2017-10-31 | 北京国双科技有限公司 | Control the method for allocating tasks and device of web crawlers |
Cited By (32)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112019454A (en) * | 2019-05-29 | 2020-12-01 | 潘仲光 | Resource processing method, device and storage medium |
CN110430229A (en) * | 2019-06-19 | 2019-11-08 | 特斯联(北京)科技有限公司 | Intelligence community Internet of Things heat transfer agent acquisition processing system and method based on cloud platform |
CN110377412A (en) * | 2019-07-24 | 2019-10-25 | 湖南快乐阳光互动娱乐传媒有限公司 | A kind of method for scheduling task and system |
CN110825732A (en) * | 2019-09-20 | 2020-02-21 | 广州亚美信息科技有限公司 | Data query method and device, computer equipment and readable storage medium |
CN110781000A (en) * | 2019-10-17 | 2020-02-11 | 中国建设银行股份有限公司 | Multi-application resource allocation method and device |
CN111552567A (en) * | 2020-04-27 | 2020-08-18 | 北京奇艺世纪科技有限公司 | Thread management method and device, electronic equipment and storage medium |
CN111625329A (en) * | 2020-05-18 | 2020-09-04 | 北京达佳互联信息技术有限公司 | Task allocation method and device, electronic equipment, server and storage medium |
CN111651272A (en) * | 2020-05-28 | 2020-09-11 | 苏州大学 | Thread time management method and device for embedded real-time operation |
CN111651272B (en) * | 2020-05-28 | 2023-02-03 | 苏州大学 | Thread time management method and device for embedded real-time operation |
CN111767125B (en) * | 2020-06-15 | 2023-07-25 | 杭州数梦工场科技有限公司 | Task execution method, device, electronic equipment and storage medium |
CN111767125A (en) * | 2020-06-15 | 2020-10-13 | 杭州数梦工场科技有限公司 | Task execution method and device, electronic equipment and storage medium |
CN111782293A (en) * | 2020-06-28 | 2020-10-16 | 珠海豹趣科技有限公司 | Task processing method and device, electronic equipment and readable storage medium |
CN111813546B (en) * | 2020-06-30 | 2022-06-07 | 济南浪潮数据技术有限公司 | Resource allocation method, system and related device for multi-network connection application |
CN111813546A (en) * | 2020-06-30 | 2020-10-23 | 济南浪潮数据技术有限公司 | Resource allocation method, system and related device for multi-network connection application |
CN111797074A (en) * | 2020-07-03 | 2020-10-20 | 中国建设银行股份有限公司 | Database connection method and device, electronic equipment and readable storage medium |
CN111709723B (en) * | 2020-07-20 | 2023-11-28 | 港胜技术服务(深圳)有限公司 | RPA business process intelligent processing method, device, computer equipment and storage medium |
CN111709723A (en) * | 2020-07-20 | 2020-09-25 | 港胜技术服务(深圳)有限公司 | RPA business process intelligent processing method, device, computer equipment and storage medium |
CN112099945A (en) * | 2020-08-20 | 2020-12-18 | 深圳市元征科技股份有限公司 | Task processing method, task processing device and electronic equipment |
CN112328634A (en) * | 2020-10-16 | 2021-02-05 | 中国建设银行股份有限公司 | Database-based operation request processing method and device |
CN112434924B (en) * | 2020-11-18 | 2021-09-14 | 广西电网有限责任公司 | Risk inspection monitoring platform based on cloud platform under full-electric-network multi-source data |
CN112434924A (en) * | 2020-11-18 | 2021-03-02 | 刘凤 | Risk inspection monitoring platform based on cloud platform under full-electric-network multi-source data |
CN112395064A (en) * | 2020-11-18 | 2021-02-23 | 中国联合网络通信集团有限公司 | Thread scheduling method and device |
CN112527509A (en) * | 2020-12-21 | 2021-03-19 | 北京百度网讯科技有限公司 | Resource allocation method and device, electronic equipment and storage medium |
CN112527509B (en) * | 2020-12-21 | 2023-09-01 | 北京百度网讯科技有限公司 | Resource allocation method and device, electronic equipment and storage medium |
CN112689007A (en) * | 2020-12-23 | 2021-04-20 | 江苏苏宁云计算有限公司 | Resource allocation method, device, computer equipment and storage medium |
CN112783659A (en) * | 2021-02-01 | 2021-05-11 | 北京百度网讯科技有限公司 | Resource allocation method and device, computer equipment and storage medium |
CN112783659B (en) * | 2021-02-01 | 2023-08-04 | 北京百度网讯科技有限公司 | Resource allocation method and device, computer equipment and storage medium |
CN112948085A (en) * | 2021-03-03 | 2021-06-11 | 杉数科技(北京)有限公司 | Task scheduling processing method and device |
CN113238501A (en) * | 2021-05-08 | 2021-08-10 | 西安联乘智能科技有限公司 | Vehicle networking control method and system based on RTOS operating system |
CN113641476B (en) * | 2021-08-16 | 2023-07-14 | 腾讯科技(深圳)有限公司 | Task scheduling method, game engine, device and storage medium |
CN113641476A (en) * | 2021-08-16 | 2021-11-12 | 腾讯科技(深圳)有限公司 | Task scheduling method, game engine, equipment and storage medium |
CN114860814A (en) * | 2022-07-05 | 2022-08-05 | 天津金城银行股份有限公司 | Credit investigation processing system, method, credit investigation system, device and medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109783229A (en) | The method and device of thread resources distribution | |
CN109710400A (en) | The method and device of thread resources grouping | |
CN106453146B (en) | Method, system, device and readable storage medium for allocating private cloud computing resources | |
CN109150607A (en) | Classification management-control method and device for block chain network | |
CN106033373B (en) | Resources of virtual machine dispatching method and scheduling system in a kind of cloud computing platform | |
CN111506404A (en) | Kubernetes-based shared GPU (graphics processing Unit) scheduling method | |
CN108667867A (en) | Date storage method and device | |
CN105959395A (en) | Cluster self-feedback type load balancing scheduling system and method | |
CN106407244A (en) | Multi-database-based data query method, system and apparatus | |
CN105872114A (en) | Video monitoring cloud platform resource scheduling method and device | |
CN110661842B (en) | Resource scheduling management method, electronic equipment and storage medium | |
CN108805655A (en) | Vehicle timesharing Sharing Management method and service platform | |
CN103593229A (en) | Integrating and uniform dispatching frame of heterogeneous cloud operation systems and dispatching method thereof | |
CN108681481A (en) | The processing method and processing device of service request | |
CN105592110A (en) | Resource scheduling method and device | |
CN105874426B (en) | A kind of batch processing method and device of system call command | |
CN109358847A (en) | A kind of Business Management Platform | |
CN107483364A (en) | A kind of scheduling of Hadoop Yarn network bandwidth resources, partition method and device | |
CN105373434A (en) | Resource management system and method | |
CN111506434A (en) | Task processing method and device and computer readable storage medium | |
CN105260244A (en) | Task scheduling method and device for distributed system | |
CN115665284A (en) | Message processing method and device based on distributed configuration center and computer equipment | |
CN108595259A (en) | A kind of internal memory pool managing method based on global administration | |
US20020023088A1 (en) | Information routing | |
CN109889406A (en) | For managing method, apparatus, equipment and the storage medium of network connection |
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 |