CN109947554A - A kind of method of the automatic recycling distribution of task time-out - Google Patents
A kind of method of the automatic recycling distribution of task time-out Download PDFInfo
- Publication number
- CN109947554A CN109947554A CN201711392986.1A CN201711392986A CN109947554A CN 109947554 A CN109947554 A CN 109947554A CN 201711392986 A CN201711392986 A CN 201711392986A CN 109947554 A CN109947554 A CN 109947554A
- Authority
- CN
- China
- Prior art keywords
- task
- queue
- time
- thread
- timed
- 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
Abstract
The invention discloses a kind of methods of the automatic recycling distribution of task time-out, are related to processing and the thread pool compounding technique field of multithreading.Method particularly includes: set the activity duration of task;Task is placed in the queue of thread pool, thread is created, starts thread;Task in user's receiving queue;User does task, submits task;Whether overtime judge submission task, if had not timed out, this task is completed, if it has timed out, then modifying state;Start timer, execute timed task at regular intervals, the task of time-out is recovered in thread pool automatically, is waited to be allocated.The technologies such as frames and multithreading such as integrated Spring and Struts, it is not only implemented conveniently, powerful, and just cooperates spring frame to use in web exploitation, is the optimal selection that overtime task is recycled in timing.
Description
Technical field
The present invention relates to a kind of methods of the automatic recycling distribution of task time-out, and in particular to the processing of multithreading and thread pool
Compounding technique field.
Background technique
In Object-Oriented Programming, creation and destroy object be time consuming because creation one object to obtain in
Deposit resource or other more resources.Even more so in java, virtual machine will attempt to track each object, so as to
Object carries out garbage reclamation after destroying.So as soon as improving service routine efficiency is the critical issue for needing to solve, in fact this
It is " pooling technology " technology Producing reason.The execution that multithreading mainly solves multiple threads in processor unit is asked
Topic, it can significantly reduce the standby time of processor unit, increase the handling capacity of processor unit.Timer user
Just, the clear specified starting time, timing parameters are more flexible, more complicated timed task easy to accomplish.
Summary of the invention
The purpose of the present invention is to provide a kind of method of the automatic recycling distribution of task time-out, such method is appointed time-out
Business is set to modification state, and then recycling waits task next time to distribute, such distribution method can be improved into queue
The utilization rate of CPU, while substantially increasing the efficiency of program.
To achieve the above object, the invention provides the following technical scheme: a kind of method of the automatic recycling distribution of task time-out
The following steps are included:
Step 1: the activity duration of setting task;
Step 2: task is placed in the queue of thread pool, thread is created, starts thread;
Step 3: the task in user's receiving queue;
Step 4: user does task, task is submitted;
Step 5: whether judge submission task overtime, if had not timed out, this task is completed, if it has timed out, being then modification shape
State;
Step 6: starting timer, executes timed task at regular intervals, the task of time-out is recovered to thread pool automatically
In, it waits to be allocated.
Preferably, in the backstage setting activity duration as designated value, the designated value is as judgement in the step one
Task whether Chao Shi foundation;
Preferably, the thread pool in the step two, is a kind of multiple threads form, adds task in treatment process
To queue, then start these tasks automatically after creating thread, and the queue referred here to, it is a kind of data structure, uses
The characteristics of chained list and array can realize, queue is exactly the data elder generation dequeue for being first put into queue;
Preferably, in the step three, after creation thread starting thread, task in queue is according to being first put into queue
The characteristics of data elder generation dequeue, is successively received by user and carries out operation.
Preferably, user makees in receiving in queue for task in the step four, step 5 and step 6
When industry, if during operation or when the time of task being submitted to already exceed the designated value set in step 1, at this moment
Determine that the task has timed, out, then the state of the system modification task, and the task of time-out is placed back in queue, most
Distribution next time is waited afterwards.
Compared with prior art, the beneficial effects of the present invention are: the frames and multithreading etc. such as integrated Spring and Struts
Technology executes timed task using timer timing scan.Complete the recycling distribution of overtime task, and the timer of spring
Function, it is not only implemented conveniently, powerful, and just cooperates spring frame to use in web exploitation, is timing
Recycle the optimal selection of overtime task.
Detailed description of the invention
Fig. 1 is flowage structure schematic diagram of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clearly and completely
Description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Based on this hair
Embodiment in bright, every other implementation obtained by those of ordinary skill in the art without making creative efforts
Example, shall fall within the protection scope of the present invention.
Present embodiment provides a kind of technical solution: referring to Fig.1, a kind of method of the automatic recycling distribution of task time-out
The following steps are included:
Step 1: the activity duration of setting task;
Step 2: task is placed in the queue of thread pool, thread is created, starts thread;
Step 3: the task in user's receiving queue;
Step 4: user does task, task is submitted;
Step 5: whether judge submission task overtime, if had not timed out, this task is completed, if it has timed out, then modifying shape
State;
Step 6: starting timer, executes timed task at regular intervals, the task of time-out is recovered to thread pool automatically
In, it waits to be allocated.
Wherein, in the step one, in the backstage setting activity duration as designated value, the designated value is as judgement task
Whether Chao Shi foundation;Thread pool in the step two is a kind of multiple threads form, adds task in treatment process
It is added to queue, then starts these tasks automatically after creating thread, and the queue referred here to, it is a kind of data structure,
It can be realized with chained list and array, the characteristics of queue is exactly the data elder generation dequeue for being first put into queue;In the step three,
After creation thread starting thread, the characteristics of task in queue is according to the data elder generation dequeue for being first put into queue, successively by with
Family, which receives, carries out operation;In the step four, step 5 and step 6, user carries out operation receiving the task in queue
When, if at this moment just sentenced during operation or when the time of task being submitted to already exceed the designated value set in step 1
The fixed task has timed, out, then the state of the system modification task, and the task of time-out is placed back in queue, finally
Wait distribution next time.
Overtime task described in present embodiment recycles automatically, is one and repeats work, wherein timer
One thread of the starting processing overtime task of timing, is then scanned, the overtime task for the state that has modified is recycled,
It can facilitate, the clear specified starting time, and timing parameters can according to need flexible, the comparison easy to accomplish that is designed comparison
Complicated timed task.
It although an embodiment of the present invention has been shown and described, for the ordinary skill in the art, can be with
A variety of variations, modification, replacement can be carried out to these embodiments without departing from the principles and spirit of the present invention by understanding
And modification, the scope of the present invention is defined by the appended.
Claims (5)
1. a kind of method of the automatic recycling distribution of task time-out, it is characterised in that: specific recycling distribution method the following steps are included:
Step 1: the activity duration of setting task;
Step 2: task is placed in the queue of thread pool, thread is created, starts thread;
Step 3: the task in user's receiving queue;
Step 4: user does task, task is submitted;
Step 5: whether judge submission task overtime, if had not timed out, this task is completed, if it has timed out, then modifying shape
State;
Step 6: starting timer, executes timed task at regular intervals, the task of time-out is recovered to thread pool automatically
In, it waits to be allocated.
2. a kind of method of the automatic recycling distribution of task time-out according to claim 1, it is characterised in that: the step
In one, in the backstage setting activity duration as designated value, the designated value as judge task whether Chao Shi foundation.
3. a kind of method of the automatic recycling distribution of task time-out according to claim 1, it is characterised in that: the step
Thread pool in two, is a kind of multiple threads form, task is added to queue in treatment process, then after creating thread
Automatically start these tasks, and the queue referred here to, it is a kind of data structure, can be realized with chained list and array, team
The characteristics of column is exactly the data elder generation dequeue for being first put into queue.
4. a kind of method of the automatic recycling distribution of task time-out according to claim 1, it is characterised in that: the step
In three, after creation thread starting thread, the characteristics of task in queue is according to the data elder generation dequeue for being first put into queue, successively
It is received by user and carries out operation.
5. a kind of method of the automatic recycling distribution of task time-out according to claim 1, it is characterised in that: the step
Four, in step 5 and step 6, user is when receiving the task progress operation in queue, if during operation or mentioned
When the time of friendship task alreadys exceed the designated value set in step 1, at this moment decide that the task has timed, out, then system
The state of the task is modified, and the task of time-out is placed back in queue, finally waits distribution next time.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711392986.1A CN109947554A (en) | 2017-12-21 | 2017-12-21 | A kind of method of the automatic recycling distribution of task time-out |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711392986.1A CN109947554A (en) | 2017-12-21 | 2017-12-21 | A kind of method of the automatic recycling distribution of task time-out |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109947554A true CN109947554A (en) | 2019-06-28 |
Family
ID=67004808
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711392986.1A Pending CN109947554A (en) | 2017-12-21 | 2017-12-21 | A kind of method of the automatic recycling distribution of task time-out |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109947554A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101599027A (en) * | 2009-06-30 | 2009-12-09 | 中兴通讯股份有限公司 | A kind of thread pool management method and system thereof |
CN102521043A (en) * | 2011-12-27 | 2012-06-27 | 广州从兴电子开发有限公司 | Task processing method and application system |
US9354931B1 (en) * | 2015-05-14 | 2016-05-31 | Tmaxsoft, Co., Ltd. | Method, server and computer-readable recording medium for managing size of thread pool dynamically |
-
2017
- 2017-12-21 CN CN201711392986.1A patent/CN109947554A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101599027A (en) * | 2009-06-30 | 2009-12-09 | 中兴通讯股份有限公司 | A kind of thread pool management method and system thereof |
CN102521043A (en) * | 2011-12-27 | 2012-06-27 | 广州从兴电子开发有限公司 | Task processing method and application system |
US9354931B1 (en) * | 2015-05-14 | 2016-05-31 | Tmaxsoft, Co., Ltd. | Method, server and computer-readable recording medium for managing size of thread pool dynamically |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN1127017C (en) | Thread switch control in mltithreaded processor system | |
CN1112636C (en) | Method and apparatus for selecting thread switch events in multithreaded processor | |
CN102541653B (en) | Method and system for scheduling multitasking thread pools | |
US20140075450A1 (en) | Multi-threaded processing with reduced context switching | |
CN106445617B (en) | Android-based application cold start optimization method and system | |
CN1828541A (en) | Implementation method for timing task in Java operating system | |
CN105760234A (en) | Thread pool management method and device | |
CN105912387A (en) | Method and device for dispatching data processing operation | |
CN111209077A (en) | Deep learning framework design method | |
CN107480041A (en) | The task automation method of testing and system of a kind of big data | |
CN106897136A (en) | A kind of method for scheduling task and device | |
CN106371927A (en) | Linux daemon process realization method and system | |
CN108958915A (en) | Timed task executes method and device | |
CN1855068A (en) | Method for testing multi-thread software concurrent conflict | |
CN1101573C (en) | Computer system | |
CN111400015A (en) | Task scheduling method and device | |
CN109947554A (en) | A kind of method of the automatic recycling distribution of task time-out | |
CN105718243A (en) | Data batch operating method and system in ERP system | |
CN1828543A (en) | Real-time task scheduling method in Java operating system | |
KR100590764B1 (en) | Method for mass data processing through scheduler in multi processor system | |
CN105931003A (en) | Order processing method, system and device | |
CN1614933A (en) | Method for updating system apparatus | |
CN112835692B (en) | Log message driven task method, system, storage medium and equipment | |
CN104679837B (en) | The processing method and processing device of keyword price adjustment request | |
CN110879726B (en) | Keep-alive method and keep-alive device for mobile terminal application program |
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 | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20190628 |