CN101719079A - Method and device for processing tasks - Google Patents

Method and device for processing tasks Download PDF

Info

Publication number
CN101719079A
CN101719079A CN200910242777A CN200910242777A CN101719079A CN 101719079 A CN101719079 A CN 101719079A CN 200910242777 A CN200910242777 A CN 200910242777A CN 200910242777 A CN200910242777 A CN 200910242777A CN 101719079 A CN101719079 A CN 101719079A
Authority
CN
China
Prior art keywords
task
obtaining
thread
executing
formation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN200910242777A
Other languages
Chinese (zh)
Inventor
孙丕石
王亚玲
曹占峰
尹洪苓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
State Grid Corp of China SGCC
China Electric Power Research Institute Co Ltd CEPRI
Original Assignee
State Grid Corp of China SGCC
China Electric Power Research Institute Co Ltd CEPRI
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by State Grid Corp of China SGCC, China Electric Power Research Institute Co Ltd CEPRI filed Critical State Grid Corp of China SGCC
Priority to CN200910242777A priority Critical patent/CN101719079A/en
Publication of CN101719079A publication Critical patent/CN101719079A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a device for processing tasks. The method comprises following steps of: acquiring tasks to be executed; adding the acquired tasks into an executing queue; monitoring the executing queue; and respectively starting executing task threads for each task while finding that a task is present in the executing queue. The method and the device ensure that the current tasks does not influence tasks behind while executing, and ensure that a plurality of tasks which are executed in the same time are processed synchronously.

Description

A kind of method of Processing tasks and device
Technical field
The present invention relates to field of computer technology, relate in particular to a kind of method and device of Processing tasks.
Background technology
Along with the development of infotech, a large amount of infosystems come into operation.In order to satisfy the logic of work, when a large amount of infosystems exists, need dispatch, and then carry out these tasks the task in these infosystems.
Existing java application adopts the timer framework to the scheduling of task, the main thread registered task, and the task of main thread registration all has the execution time separately, after main thread starts, activate background thread, background thread is obtained from task queue and is arranged in top task, judges the current time not exceed the task executions time of being obtained, and then carries out this task.
The inventor is in research process, there is following shortcoming at least in the existing scheme that discovery is dispatched and carried out task: current task when carrying out if consuming time long, perhaps, take place unusual, make the task of being arranged in the current task back overtime easily, even the time exceeds the back task executions time, thereby influence the back task executions.Simultaneously, if there are a plurality of tasks to need to carry out at one time, then existing scheme can't realize.
Summary of the invention
In view of this, the embodiment of the invention provides a kind of method and device of Processing tasks, so that current task does not influence the task of being arranged in the back when carrying out, simultaneously, allows a plurality of carrying out at one time of tasks simultaneously processed.
A kind of method of Processing tasks, described method comprises:
Obtain pending task;
Obtaining of task is added into execution formation;
Described execution formation is monitored;
When in finding described execution formation, task being arranged, be respectively each task start thread of executing the task.
Alternatively, described obtaining of task is added into execution formation before, described method also comprises:
Judge whether the current time exceeded the task executions time of obtaining,, then continue to carry out next step if do not exceed the task executions time of obtaining.
Alternatively, described obtaining of task is added into execution formation after, described method also comprises:
Judge whether obtaining of task needs to repeat, if, then upgrade the execution time according to the task executions cycle of obtaining, otherwise, the task that deletion is obtained.
Alternatively, execute the task after the thread at described each task start that is respectively, described method also comprises:
Judge whether the thread of respectively executing the task has taken place unusually, if do not take place unusual, flow process finishes, if taken place unusual, when satisfying specified conditions,, the unusual performed task of the thread of executing the task adds into unusual formation with taking place, perhaps, with taking place, the unusual performed task of the thread of executing the task adds into execution formation again.
A kind of device of Processing tasks, described device comprises:
Scheduling unit is used to obtain pending task, and obtaining of task is added into execution formation;
Performance element is used for described execution formation is monitored, and when in finding described execution formation task being arranged, is respectively each task start thread of executing the task.
Alternatively, described scheduling unit comprises:
Obtain subelement, be used to obtain pending task;
First judging unit is used to judge whether the current time has exceeded the task executions time of obtaining;
Add subelement, be used for then obtaining of task being added into execution formation if described first judgment unit judges goes out not exceed the task executions time of obtaining.
Alternatively, described scheduling unit also comprises:
Second judging unit is used to judge whether obtaining of task needs to repeat, if, then according to the more capable execution time in task executions cycle of obtaining, otherwise, the task that deletion is obtained.
Alternatively, described performance element also comprises:
The 3rd judging unit, be used for judging whether the thread of respectively executing the task has taken place unusually, if taken place unusual, when satisfying specified conditions,, the unusual performed task of the thread of executing the task adds into unusual formation with taking place, perhaps, with taking place, the unusual performed task of the thread of executing the task adds into execution formation again.
As can be seen, in inventive embodiments, obtain pending task earlier, obtaining of task is added into execution formation, monitor,, be respectively each task start thread of executing the task when finding to carry out when in the formation task being arranged to carrying out formation.Because each pending task will have the thread of executing the task separately, therefore, can not influence other task executions, simultaneously, can handle a plurality of pending tasks at one time.
Description of drawings
Fig. 1 is the embodiment of the invention one method flow diagram;
Fig. 2 is the embodiment of the invention two method flow diagrams;
The apparatus structure block diagram that Fig. 3 provides for the embodiment of the invention three;
The apparatus structure block diagram that Fig. 4 provides for the embodiment of the invention four.
Embodiment
For above-mentioned feature, the advantage that makes the embodiment of the invention becomes apparent more, be elaborated below in conjunction with embodiment.
Please refer to Fig. 1, be the embodiment of the invention one method flow diagram, can may further comprise the steps:
Step 101: obtain pending task;
Step 102: obtaining of task is added into execution formation;
Step 103: described execution formation is monitored;
Step 104: when in finding described execution formation, task being arranged, be respectively each task start thread of executing the task.
As can be seen, in inventive embodiments, obtain pending task earlier, obtaining of task is added into execution formation, monitor,, be respectively each task start thread of executing the task when finding to carry out when in the formation task being arranged to carrying out formation.Because each pending task will have the thread of executing the task separately, therefore, can not influence other task executions, simultaneously, can handle a plurality of pending tasks at one time.
Below with one more specific embodiment the present invention will be described.
After main thread starts, activate background thread, background thread is dispatched the task in the scheduling queue, obtains task from scheduling queue, and obtaining of task is added into execution formation, and, background thread will judge also whether obtaining of task needs to repeat, if upgrade its execution time according to the task executions cycle of obtaining, otherwise, obtaining of task is deleted from scheduling queue.Watcher thread is monitored carrying out formation, carries out when in the formation task being arranged when listening to, and then obtains task from carry out formation, and is thread of executing the task of each task start, the execution of being finished the work by the thread of executing the task.
Please refer to Fig. 2, be the embodiment of the invention two method flow diagrams, can may further comprise the steps:
Step 201: main thread registered task;
Need all be registered to main thread by the task that the method that the embodiment of the invention provides is handled, the task of main thread registration all has the execution time separately.
Step 202: after task was handled and started, main thread activated background thread;
Step 203: background thread is obtained pending task according to the task priority order from scheduling queue;
The priority of need carrying out simultaneously of task can be identical.
Step 204: background thread judges whether the current time has exceeded the task executions time of obtaining, if, arrive task executions next pending in the scheduling queue during time when the time, return step 203, otherwise, obtaining of task is added into execution formation, enter step 205, simultaneously, enter step 206;
Step 205: background thread judges whether obtaining of task needs to repeat, if, upgrade its execution time according to this task executions cycle, and return step 203, otherwise, delete this task, flow process finishes;
Step 206: watcher thread is monitored and is carried out formation, when in finding the execution formation task being arranged, obtains carrying out in the formation of task according to the priority of task;
Carrying out in the formation of task can also perhaps manually be set from other thread.And need the task priority of execution simultaneously identical.
Step 207: watcher thread is thread of executing the task of each task start that obtains, by each thread execution task separately of executing the task;
It is pointed out that the number of threads of executing the task that watcher thread starts can be configured as required, the number of the task of execution has exceeded the quantity of configuration if need simultaneously, then carries out according to the priority orders of task.
Step 208: watcher thread judges whether each thread of executing the task has taken place unusually, if enter step 209, otherwise flow process finishes;
Step 209: watcher thread judges that whether the unusual unusual number of times of the thread of executing the task of generation is greater than 3, if greater than, the performed task of thread of then this being executed the task is added into unusual formation, and send alarm, otherwise, the task that this thread of executing the task is performed is added into execution formation again, so that watcher thread is task execution thread of this task start again.
After background thread and watcher thread were complete, the flow process of main thread finished.
For ease of understanding, with an instantiation embodiment of the invention is described below.
Suppose that a group company has all set up branch office in various places, need swap data between each branch office, between branch office so the lot of data switching task is arranged.Adopt the embodiment of the invention, after main thread starts, activate background thread, background thread is dispatched the exchanges data task in the scheduling queue, and the exchanges data task of obtaining is added into execution formation.Watcher thread listens to be carried out when in the formation task being arranged, and obtains carrying out in the formation of task, and for thread of executing the task of each task start that obtains, finishes the exchanges data task by the thread of respectively executing the task.
As can be seen, in embodiments of the present invention, watcher thread is respectively thread of executing the task of each task start, by each thread execution task separately of executing the task, therefore, when a task consuming time in the process of implementation long, perhaps, take place can not influence other task executions unusually, simultaneously, the task that a plurality of needs are carried out at one time can be carried out simultaneously, and in addition, background thread or watcher thread all are to obtain task according to task priority, efficiently solve priority control problem, and can handle considerable task simultaneously.
Please refer to Fig. 3, the apparatus structure block diagram for the embodiment of the invention three provides can comprise:
Scheduling unit 301 is used to obtain pending task, and obtaining of task is added into execution formation;
Performance element 302 is used for described execution formation is monitored, and when in finding described execution formation task being arranged, is respectively each task start thread of executing the task.
As can be seen, in inventive embodiments, obtain pending task earlier, obtaining of task is added into execution formation, monitor,, be respectively each task start thread of executing the task when finding to carry out when in the formation task being arranged to carrying out formation.Because each pending task will have the thread of executing the task separately, therefore, can not influence other task executions, simultaneously, can handle a plurality of pending tasks at one time.
Please refer to Fig. 4, the apparatus structure block diagram for the embodiment of the invention four provides can comprise:
Scheduling unit 301 is used to obtain pending task, and obtaining of task is added into execution formation;
Performance element 302 is used for described execution formation is monitored, and when in finding described execution formation task being arranged, is respectively each task start thread of executing the task.
Scheduling unit 301 can comprise:
Obtain subelement 401, be used to obtain pending task;
First judging unit 402 is used to judge whether the current time has exceeded the task executions time of obtaining;
Add subelement 403, be used for then obtaining of task being added into execution formation if described first judging unit 402 is judged and do not exceeded the task executions time of obtaining.
Described scheduling unit 301 can also comprise:
Second judging unit 404 is used to judge whether obtaining of task needs to repeat, if, then according to the more capable execution time in task executions cycle of obtaining, otherwise, the task that deletion is obtained.
Described performance element 302 can also comprise:
The 3rd judging unit 405, be used for judging whether the thread of respectively executing the task has taken place unusually, if taken place unusual, when satisfying specified conditions,, the unusual performed task of the thread of executing the task adds into unusual formation with taking place, perhaps, with taking place, the unusual performed task of the thread of executing the task adds into execution formation again.
It is to be noted, the scheduling unit 301 that the embodiment of the invention provides can separate with performance element 302 to be disposed, and scheduling unit 301 can add the different task of obtaining into a plurality of execution formations, performance element 302 can be deployed on a plurality of servers, each is carried out formation monitors, and then can improve the ability of parallel processing, satisfy the requirement that considerable task is handled.
At last, also need to prove, in this article, relational terms such as first and second grades only is used for an entity or operation are made a distinction with another entity or operation, and not necessarily requires or hint and have the relation of any this reality or in proper order between these entities or the operation.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thereby make and comprise that process, method, article or the equipment of a series of key elements not only comprise those key elements, but also comprise other key elements of clearly not listing, or also be included as this process, method, article or equipment intrinsic key element.Do not having under the situation of more restrictions, the key element that limits by statement " comprising ... ", and be not precluded within process, method, article or the equipment that comprises described key element and also have other identical element.
Through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential hardware platform, can certainly all implement, but the former is better embodiment under a lot of situation by hardware.Based on such understanding, all or part of can the embodying that technical scheme of the present invention contributes to background technology with the form of software product, this computer software product can be stored in the storage medium, as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are with so that a computer equipment (can be a personal computer, server, the perhaps network equipment etc.) carry out the described method of some part of each embodiment of the present invention or embodiment.
More than the present invention is described in detail, used specific case herein principle of the present invention and embodiment set forth, the explanation of above embodiment just is used for help understanding method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that all can change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.

Claims (8)

1. the method for a Processing tasks is characterized in that, described method comprises:
Obtain pending task;
Obtaining of task is added into execution formation;
Described execution formation is monitored;
When in finding described execution formation, task being arranged, be respectively each task start thread of executing the task.
2. method according to claim 1 is characterized in that, described obtaining of task is added into execution formation before, described method also comprises:
Judge whether the current time exceeded the task executions time of obtaining,, then continue to carry out next step if do not exceed the task executions time of obtaining.
3. method according to claim 1 is characterized in that, described obtaining of task is added into execution formation after, described method also comprises:
Judge whether obtaining of task needs to repeat, if, then upgrade the execution time according to the task executions cycle of obtaining, otherwise, the task that deletion is obtained.
4. method according to claim 1 is characterized in that, executes the task after the thread at described each task start that is respectively, and described method also comprises:
Judge whether the thread of respectively executing the task has taken place unusually, if do not take place unusual, flow process finishes, if taken place unusual, when satisfying specified conditions,, the unusual performed task of the thread of executing the task adds into unusual formation with taking place, perhaps, with taking place, the unusual performed task of the thread of executing the task adds into execution formation again.
5. the device of a Processing tasks is characterized in that, described device comprises:
Scheduling unit is used to obtain pending task, and obtaining of task is added into execution formation;
Performance element is used for described execution formation is monitored, and when in finding described execution formation task being arranged, is respectively each task start thread of executing the task.
6. device according to claim 5 is characterized in that, described scheduling unit comprises:
Obtain subelement, be used to obtain pending task;
First judging unit is used to judge whether the current time has exceeded the task executions time of obtaining;
Add subelement, be used for then obtaining of task being added into execution formation if described first judgment unit judges goes out not exceed the task executions time of obtaining.
7. device according to claim 5 is characterized in that, described scheduling unit also comprises:
Second judging unit is used to judge whether obtaining of task needs to repeat, if, then according to the more capable execution time in task executions cycle of obtaining, otherwise, the task that deletion is obtained.
8. device according to claim 5 is characterized in that, described performance element also comprises:
The 3rd judging unit, be used for judging whether the thread of respectively executing the task has taken place unusually, if taken place unusual, when satisfying specified conditions,, the unusual performed task of the thread of executing the task adds into unusual formation with taking place, perhaps, with taking place, the unusual performed task of the thread of executing the task adds into execution formation again.
CN200910242777A 2009-12-17 2009-12-17 Method and device for processing tasks Pending CN101719079A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910242777A CN101719079A (en) 2009-12-17 2009-12-17 Method and device for processing tasks

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910242777A CN101719079A (en) 2009-12-17 2009-12-17 Method and device for processing tasks

Publications (1)

Publication Number Publication Date
CN101719079A true CN101719079A (en) 2010-06-02

Family

ID=42433657

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910242777A Pending CN101719079A (en) 2009-12-17 2009-12-17 Method and device for processing tasks

Country Status (1)

Country Link
CN (1) CN101719079A (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101923493A (en) * 2010-09-21 2010-12-22 深圳市华力特电气股份有限公司 Task scheduling method and task scheduling equipment
CN102611642A (en) * 2012-02-27 2012-07-25 杭州闪亮科技有限公司 System for processing nonsynchronous message and method for system to send message and monitor processing task
CN102929709A (en) * 2011-08-08 2013-02-13 阿里巴巴集团控股有限公司 Method and device for treating abnormality of task flows
CN103530898A (en) * 2013-01-06 2014-01-22 Tcl集团股份有限公司 Animation processing method and system based on 3D real-time rendering
CN104572270A (en) * 2015-01-26 2015-04-29 浪潮通用软件有限公司 Task execution method and device based on message queue
CN105930208A (en) * 2016-04-01 2016-09-07 广州华多网络科技有限公司 Thread scheduling method and thread scheduling apparatus
CN106155796A (en) * 2016-07-25 2016-11-23 浪潮(北京)电子信息产业有限公司 A kind of thread scheduling method based on queue and device
CN106354552A (en) * 2015-07-17 2017-01-25 宁波森浦融讯科技有限公司 Parallel Computer Task Distribution Method and Device
CN107291547A (en) * 2016-03-31 2017-10-24 阿里巴巴集团控股有限公司 A kind of task scheduling processing method, apparatus and system
CN109739660A (en) * 2018-12-24 2019-05-10 新华三技术有限公司合肥分公司 Unexpected message processing method and processing device
CN110096353A (en) * 2019-05-14 2019-08-06 厦门美图之家科技有限公司 Method for scheduling task and device
CN110109760A (en) * 2019-05-10 2019-08-09 深圳前海达闼云端智能科技有限公司 Memory resource control method and device
CN110245011A (en) * 2018-03-08 2019-09-17 北京京东尚科信息技术有限公司 A kind of method for scheduling task and device
CN113742071A (en) * 2021-09-03 2021-12-03 北京淳中科技股份有限公司 Task processing method and electronic equipment

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101923493A (en) * 2010-09-21 2010-12-22 深圳市华力特电气股份有限公司 Task scheduling method and task scheduling equipment
CN102929709A (en) * 2011-08-08 2013-02-13 阿里巴巴集团控股有限公司 Method and device for treating abnormality of task flows
CN102611642A (en) * 2012-02-27 2012-07-25 杭州闪亮科技有限公司 System for processing nonsynchronous message and method for system to send message and monitor processing task
CN103530898B (en) * 2013-01-06 2017-04-05 Tcl集团股份有限公司 A kind of animation processing method and system based on 3D real-time renderings
CN103530898A (en) * 2013-01-06 2014-01-22 Tcl集团股份有限公司 Animation processing method and system based on 3D real-time rendering
CN104572270A (en) * 2015-01-26 2015-04-29 浪潮通用软件有限公司 Task execution method and device based on message queue
CN106354552B (en) * 2015-07-17 2019-08-06 宁波森浦融讯科技有限公司 Parallel computation method for allocating tasks and device
CN106354552A (en) * 2015-07-17 2017-01-25 宁波森浦融讯科技有限公司 Parallel Computer Task Distribution Method and Device
CN107291547A (en) * 2016-03-31 2017-10-24 阿里巴巴集团控股有限公司 A kind of task scheduling processing method, apparatus and system
CN107291547B (en) * 2016-03-31 2021-02-05 创新先进技术有限公司 Task scheduling processing method, device and system
CN105930208A (en) * 2016-04-01 2016-09-07 广州华多网络科技有限公司 Thread scheduling method and thread scheduling apparatus
CN106155796A (en) * 2016-07-25 2016-11-23 浪潮(北京)电子信息产业有限公司 A kind of thread scheduling method based on queue and device
CN110245011A (en) * 2018-03-08 2019-09-17 北京京东尚科信息技术有限公司 A kind of method for scheduling task and device
CN109739660A (en) * 2018-12-24 2019-05-10 新华三技术有限公司合肥分公司 Unexpected message processing method and processing device
CN109739660B (en) * 2018-12-24 2020-10-16 新华三技术有限公司合肥分公司 Abnormal message processing method and device
CN110109760A (en) * 2019-05-10 2019-08-09 深圳前海达闼云端智能科技有限公司 Memory resource control method and device
CN110109760B (en) * 2019-05-10 2021-07-02 达闼机器人有限公司 Memory resource control method and device
CN110096353A (en) * 2019-05-14 2019-08-06 厦门美图之家科技有限公司 Method for scheduling task and device
CN110096353B (en) * 2019-05-14 2021-11-30 厦门美图之家科技有限公司 Task scheduling method and device
CN113742071A (en) * 2021-09-03 2021-12-03 北京淳中科技股份有限公司 Task processing method and electronic equipment

Similar Documents

Publication Publication Date Title
CN101719079A (en) Method and device for processing tasks
CN106802826B (en) Service processing method and device based on thread pool
CN106059825A (en) Distributed system and configuration method
CN105760240A (en) Distributed task processing method and device
US20120297393A1 (en) Data Collecting Method, Data Collecting Apparatus and Network Management Device
CN107807815B (en) Method and device for processing tasks in distributed mode
JP2007215005A5 (en)
CN109800204B (en) Data distribution method and related product
CN113220431B (en) Cross-cloud distributed data task scheduling method, device and storage medium
CN104238999B (en) A kind of method for scheduling task and device based on horizontal partitioning distributed data base
CN103365718A (en) Thread scheduling method, thread scheduling device and multi-core processor system
CN106339217B (en) Event management method and system based on Unity
CN102081554A (en) Cloud computing operating system as well as kernel control system and method thereof
CN104168310A (en) Method and apparatus for scheduling cloud end vertual server
CN103645904A (en) Cache realization method of interface calling
CN102591658A (en) Method and device for processing message
CN111367693A (en) Method, system, device and medium for scheduling plug-in tasks based on message queue
CN102420709A (en) Method and equipment for managing scheduling task based on task frame
CN103399791A (en) Method and device for migrating virtual machines on basis of cloud computing
CN102402457A (en) Method for processing mobile phone application program alterative events
CN106062738A (en) Managing job status
CN110868330B (en) Evaluation method, device and evaluation system for CPU resources which can be divided by cloud platform
CN102591714B (en) Process calling method, system and application server
CN108021688B (en) A kind of data processing method and device
CN111008146A (en) Method and system for testing safety of cloud host

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20100602