CN106998349A - Multithreading method for down loading and device - Google Patents
Multithreading method for down loading and device Download PDFInfo
- Publication number
- CN106998349A CN106998349A CN201610908996.5A CN201610908996A CN106998349A CN 106998349 A CN106998349 A CN 106998349A CN 201610908996 A CN201610908996 A CN 201610908996A CN 106998349 A CN106998349 A CN 106998349A
- Authority
- CN
- China
- Prior art keywords
- thread
- download
- speed
- increase
- reduce
- 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
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
- H04L67/1074—Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
- H04L67/1078—Resource delivery mechanisms
- H04L67/1085—Resource delivery mechanisms involving dynamic management of active down- or uploading connections
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/06—Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/50—Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The present invention relates to a kind of multithreading method for down loading.It the described method comprises the following steps:Download instruction is received, file destination is downloaded according to the thread that the download instruction opens default concurrent thread quantity;Performed during download:Thread is increased or decreased, every time after increase thread, if the speed of download after increase thread is more than the speed of download before increase thread, continues to increase thread, otherwise reduces thread;Reduce every time after thread, if reducing the speed of download after thread is more than the speed of download reduced before thread, continues to reduce thread, otherwise increase thread.Above-mentioned multithreading method for down loading, can adjust automatically number of threads, make full use of bandwidth, and reduce system resources consumption as far as possible.It also provided is a kind of multithreading download apparatus.
Description
Technical field
The present invention relates to network technique field, more particularly to a kind of multithreading method for down loading and device.
Background technology
With the development of Internet technology, people can obtain various resources from network by downloading.Such as
Fruit is downloaded by single thread, due to the limitation of TCP window size, and it is difficult to make full use of the network bandwidth that single thread, which is downloaded, downloads speed
Degree can not be fully played.So increasing download tool and website start to allow user to carry out multithreading download.
Thread can be understood as the passage downloaded, and a thread is exactly the download channel of a file, and multithreading is namely opened simultaneously
Multiple download channels.Downloaded, while opening multiple download channels, it is possible to increase bandwidth availability ratio, and carried by opening multithreading
High speed of download.
But general multithreading download tool needs user manual or system sets concurrent thread quantity automatically, and simultaneously
Send out number of threads once it is determined that, just will not be changed in whole file download process.When concurrent thread quantity is excessive, it can lead
Cause the distribution of each thread download fragment it is too small, so as to cause unnecessary overhead, but also bandwidth can be taken, cause net
Network congestion, causes data delay and the possibility lost to greatly increase, speed of download is not increased counter subtract.When concurrent thread quantity mistake
It is few, it can cause that bandwidth can not be made full use of again, so as to speed of download can be caused slow.And network environment be often it is unstable,
The transmission speed of network data can not be always maintained at stabilization, during download, the concurrent thread quantity pre-set, it is difficult to abundant
While using bandwidth, system resource overhead is reduced as far as possible.
The content of the invention
Based on this, it is necessary to provide a kind of multithreading method for down loading and device, the same of the network bandwidth can made full use of
When, reduce system resource overhead.
A kind of multithreading method for down loading, including:
Download instruction is received, under the thread for opening default concurrent thread quantity according to download instruction is carried out to file destination
Carry;
Performed during download:Thread is increased or decreased, every time after increase thread, if the download speed after increase thread
Degree is more than the speed of download before increase thread, then continues to increase thread, otherwise reduce thread;Reduce every time after thread, if reducing
Speed of download after thread is more than the speed of download reduced before thread, then continues to reduce thread, otherwise increase thread.
In one of the embodiments, download instruction is being received, the thread of predetermined number is opened to mesh according to download instruction
Before mark file is downloaded, in addition to:
Network type is obtained, corresponding default concurrent thread quantity is set according to network type.
In one of the embodiments, every time after increase thread, if the speed of download after increase thread is more than increase thread
Preceding speed of download, then continue to increase thread, otherwise reduce thread, including:
Every time after increase thread, the speed of download after preset time starts to compare increase thread is with increasing before thread
Speed of download, if the speed of download after increase thread is more than the speed of download before increase thread, continues to increase thread, otherwise subtracts
Few thread;
Reduce after thread, if reducing the speed of download after thread is more than the speed of download reduced before thread, continue every time
Thread is reduced, otherwise increases thread, including:
Reduce every time after thread, start to compare the speed of download after reducing thread by preset time and reduce before thread
Speed of download, if reducing the speed of download after thread is more than the speed of download reduced before thread, continues to reduce thread, otherwise increases
Ledger line journey.
In one of the embodiments, every time after increase thread, if the speed of download after increase thread is more than increase thread
Preceding speed of download, then continue to increase thread, otherwise reduce thread, including:
Every time after increase thread, if the speed of download after increase thread is more than the speed of download before increase thread, and increase
Speed of download after thread then continues to increase thread, otherwise reduces thread not less than default speed of download threshold value;
Reduce after thread, if reducing the speed of download after thread is more than the speed of download reduced before thread, continue every time
Thread is reduced, otherwise increases thread, including:
Reduce after thread, if reducing the speed of download after thread is more than the speed of download reduced before thread, and reduce every time
Speed of download after thread then continues to reduce thread, otherwise increases thread not less than default speed of download threshold value.
In one of the embodiments, method also includes:
When the downloading task of all threads is complete, by All Files fragment combination into file destination.
A kind of multithreading download apparatus, including:
Download module, for receiving download instruction, the thread of default concurrent thread quantity is opened to mesh according to download instruction
Mark file is downloaded;
Thread control module, in downloading process, increasing or decreasing thread, every time after increase thread, if increase line
Speed of download after journey is more than the speed of download before increase thread, then continues to increase thread, otherwise reduce thread;Line is reduced every time
Cheng Hou, if reducing the speed of download after thread is more than the speed of download before reducing, continues to reduce thread, otherwise increases thread.
In one of the embodiments, device also includes:
Thread setup module, for receiving download instruction, the thread of predetermined number is opened to target according to download instruction
Before file is downloaded, network type is obtained, corresponding default concurrent thread quantity is set according to network type.
In one of the embodiments, thread control module is used in downloading process, increases or decreases thread, increases every time
After ledger line journey, the speed of download after preset time starts to compare increase thread and the speed of download before increase thread, if increasing
Speed of download after ledger line journey is more than the speed of download before increase thread, then continues to increase thread, otherwise reduce thread;
Thread control module is additionally operable to reduce after thread every time, starts to compare the download after reducing thread by preset time
Speed is with reducing the speed of download before thread, if reducing the speed of download after thread is more than the speed of download reduced before thread,
Continue to reduce thread, otherwise increase thread.
In one of the embodiments, thread control module is additionally operable in downloading process, increases or decreases thread, every time
Increase after thread, if the speed of download after increase thread is more than the download after the speed of download before increase thread, and increase thread
Speed then continues to increase thread, otherwise reduces thread not less than default speed of download threshold value;
Thread control module is additionally operable to reduce after thread every time, is reduced if reducing the speed of download after thread and being more than before thread
Speed of download, and reduce the speed of download after thread and continue to reduce thread not less than default speed of download threshold value, then, otherwise increase
Ledger line journey.
In one of the embodiments, device also includes:
File combination module, for when the downloading task of all threads is complete, by All Files fragment combination into
File destination.
Above-mentioned multithreading method for down loading and device, during download, by dynamic regulation concurrent thread quantity, work as increasing
When adduction hair number of threads can accelerate speed of download, continue to increase concurrent thread quantity, otherwise reduce concurrent thread quantity;When
When reducing concurrent thread quantity and can accelerate speed of download, continue to reduce concurrent thread quantity, otherwise increase concurrent thread quantity,
It can be always maintained at speed of download most fast, bandwidth can be made full use of in downloading process always, and reduce system resource as far as possible
Expense.
Brief description of the drawings
Fig. 1 is the flow chart of multithreading method for down loading in one embodiment;
Fig. 2 is the flow chart of one embodiment thread regulating and controlling of quantities;
Fig. 3 is the flow chart of another embodiment thread regulating and controlling of quantities;
Fig. 4 is the module map of multithreading download apparatus in one embodiment;
Fig. 5 is the module map of multithreading download apparatus in another embodiment.
Embodiment
In order that the purpose, technical scheme and advantage of the embodiment of the present invention are clearer, below in conjunction with accompanying drawing to this hair
Bright embodiment is described in further detail.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention,
It is not intended to limit the present invention.
As shown in figure 1, there is provided a kind of multithreading method for down loading in one embodiment.This method specifically includes as follows
Step:
Step 101, download instruction is received, the thread of default concurrent thread quantity is opened to file destination according to download instruction
It is downloaded.
In the present embodiment, after terminal receives download instruction, can locally it divided according to the size of file destination first
It is used for stored target file with correspondingly sized space, then according to default concurrent thread quantity, file destination is divided into accordingly
The multistage of quantity, the thread for being then turned on respective numbers is downloaded to these file destinations section respectively, when under all threads
When load task is completed, during whole file destination is with regard to being all downloaded to locally.
Step 103, performed during download:Thread is increased or decreased, every time after increase thread, if after increase thread
Speed of download be more than increase thread before speed of download, then continue increase thread, otherwise reduce thread;Thread is reduced every time
Afterwards, if reducing the speed of download after thread is more than the speed of download reduced before thread, continue to reduce thread, otherwise increase line
Journey.
In the present embodiment, the dynamic regulation concurrent thread quantity in downloading process is passed through so that open minimal number of
Thread can make speed of download keep maximum, can make full use of the network bandwidth, and reduce the consumption of system resource as far as possible.
In one embodiment, the idiographic flow of step 103 is as shown in Fig. 2 comprise the following steps:
Step 1031, thread is increased.
Step 1033, judge to increase the speed of download whether speed of download after thread is more than before increase thread, if so, then
Return to step 1031, if it is not, into step 1035.
Step 1035, thread is reduced.
Step 1037, judge to reduce whether the speed of download after thread is more than the speed of download reduced before thread, if so, then
Return to step 1035, if it is not, then return to step 1031.
In the present embodiment, it is no shadow first to increase the result that still first reduction thread is adjusted to whole concurrent thread quantity
Loud.In the present embodiment, first increase thread, if the speed of download after increase thread is more than the speed of download before increase thread,
Show not making full use of bandwidth before increase number of threads, after increase thread, the network bandwidth may not be fully utilized yet, under
Carry speed and there may be the space continued to lift up, so continuing to be further added by thread.
If the speed of download after increase number of threads is not more than the speed of download before increase thread, show current thread number
Amount all takes bandwidth, and causes network congestion, thread can be now reduced, to avoid network congestion.
If reducing the speed of download after thread is more than the speed of download reduced before thread, show to reduce before thread just
Bandwidth is taken, reduced after thread, although alleviate network congestion, but it is possible to not being eliminated, institute the problem of network congestion
To need to continue to reduce number of threads.If reducing the speed of download after number of threads is less than the speed of download reduced before thread,
The number of threads for showing to reduce before thread is more abundant to the utilization of bandwidth after thread than reducing, so needing to increase Thread Count
Amount.
Because download environment can change always over time, after the process that an increase and decrease thread is completed every time, it will continue
This process is circulated, number of threads is always maintained at making speed of download most with environmental changes such as network condition, system statuses
Greatly, bandwidth is made full use of, and reduces the state of system resources consumption as far as possible.
But, it is also to need certain time that download environment changes over time, and generally, download environment can't
Change a lot in a short time suddenly.So when have passed through one time increase and decrease thread operation after, the Thread Count after adjustment
Amount can keep the optimum state for making full use of bandwidth and reducing system resources consumption as far as possible in certain period of time.If at once
The process of increase and decrease thread is continued cycling through, number of threads can be caused to adjust always, it is impossible to keep this optimum state.So every
After the secondary process for completing an increase and decrease thread, it can be recycled for increasing and decreasing the process of thread after preset time so that many
Thread is downloaded can keep the optimum state for making full use of and reducing system resource overhead as far as possible to bandwidth within a period of time.
The process how long specific process recycles increase and decrease thread can be by artificially setting, can also be by system automatically according to current
Network fluctuation situation is adjusted.
When adjusting number of threads, multiple threads can be increased or decreased every time, one can also be only increased or decreased every time
Individual thread.Increasing or decreasing multiple threads every time the number of threads of unlatching can be made to reach as early as possible makes full use of bandwidth resources,
And the state of system resources consumption is reduced as far as possible, but because the thread increased or decreased every time is excessive, it will cause to Thread Count
Amount regulation and control are not accurate enough;A thread can also be only increased or decreased every time, but the process that again number of threads can so regulated and controled
It is elongated.In order to solve these problems, in one embodiment, multiple threads are first increased or decreased every time, increase and decrease when completing one time
After the process of thread, then by each increase thread or reduce the quantity of thread and be adjusted to one, can thread regulation and control are not only fast but also
Accurately adjust to bandwidth can be made full use of, the state of system resources consumption can be reduced as far as possible again.
In one embodiment, download instruction is being received, the thread of predetermined number is opened to target text according to download instruction
Before part is downloaded, in addition to:Network type is obtained, corresponding default concurrent thread quantity is set according to network type.
In the present embodiment, before downloading task is opened, the network type currently connected, network type bag also to be obtained
Wired network and wireless network are included, wireless network includes WIFI and mobile Internet again, and mobile Internet includes 2G networks, 3G nets
Network, 4G networks etc..According to the network type connected, can tentatively judge amount of bandwidth, be with roomy network such as WIFI or
4G networks etc. set more concurrent thread quantity, are that the small network of bandwidth such as 2G networks etc. set less concurrent thread number
Amount.
In the present embodiment, by obtaining network type, corresponding default concurrent thread quantity is set according to network type,
Can be more nearly default concurrent thread quantity can either make full use of bandwidth, can reduce as far as possible again system consumption and hair line
The optimum value of number of passes amount so that during download, more quick can arrive optimum value by the regulation of concurrent thread quantity.
In one embodiment, every time after increase thread, if the speed of download after increase thread is more than increase thread money
Speed of download, then continue to increase thread, otherwise reduce thread, including:Every time after increase thread, start to compare by preset time
Increase the speed of download after thread and the speed of download of increase thread money, if the speed of download after increase thread is more than increase thread
Preceding speed of download, then continue to increase thread, otherwise reduce thread;Reduce every time after thread, if reducing the download speed after thread
Degree is more than the speed of download reduced before thread, then continues to reduce thread, otherwise increase thread, including:Reduce every time after thread, warp
Cross preset time and start to compare the speed of download after reduction thread and the speed of download before reduction thread, if under reducing after thread
Carry speed and be more than the speed of download reduced before thread, then continue to reduce thread, otherwise increase thread.
In the present embodiment, increase or decrease every time after number of threads, speed of download may all change, and download
The change of speed is to need a process, if increased or decreased every time after number of threads, its speed of download is detected immediately, this
When speed of download be also not reaching to stable state, the confidence level of the speed of download detected is very low, be used directly to and increase or
The speed of download before thread is reduced to be compared it is possible that error, so needing after number of threads is increased or decreased, is passed through
Preset time is crossed to carry out to increasing or decreasing the speed of download after number of threads and increasing or decreasing the speed of download before thread again
Compare.
In the present embodiment, increase or decrease after number of threads, start to compare by preset time and increase or decrease thread
Speed of download after quantity can avoid speed of download from not yet reaching stabilization with increasing or decreasing the speed of download before number of threads
During state, just it is used to and increases or decreases the speed of download before number of threads and be compared, can make each time to thread
Adjustment is more accurate.
In one embodiment, every time after increase thread, if the speed of download after increase thread is more than before increase thread
Speed of download, then continue to increase thread, otherwise reduce thread, including:Every time after increase thread, if the download speed after increase thread
Degree is more than the speed of download after the speed of download before increase thread, and increase thread not less than default speed of download threshold value, then after
Continuous increase thread, otherwise reduces thread;Reduce after thread, reduced if reducing the speed of download after thread and being more than before thread every time
Speed of download, then continue to reduce thread, otherwise increase thread, including:Reduce every time after thread, if reducing the download speed after thread
Degree is more than the speed of download reduced before thread, and reduces the speed of download after thread not less than default speed of download threshold value, then after
It is continuous to reduce thread, otherwise increase thread.
In the present embodiment, increase or decrease after thread, speed of download may increase, and increase the occupancy of bandwidth, and
It is currently running in system inside task, it is necessary to which take certain bandwidth might not only have downloading task, if downloading task will
Bandwidth all takes, it will the normal work to other tasks causes extreme influence, so in order to ensure the normal of other tasks
Work, can make downloading task take as far as possible many bandwidth, reach speed of download as quickly as possible again, under being set for downloading task
Threshold speed is carried, is increased or decreased every time after number of threads, whether detection speed of download is more than pre-set velocity threshold value, if super
Pre-set velocity threshold value has been crossed, then can correspondingly decrease or increase number of threads, speed of download is kept maximum and is no more than default
Threshold speed.
In the present embodiment, by setting speed of download threshold value so that the quantity of download thread will not be complete by all bandwidth
Portion takes, it is ensured that other need the task of occupied bandwidth being capable of normal work.Certainly, the normal work of various tasks is not only needed
Want bandwidth, in addition it is also necessary to the system resource such as various cpu resources and memory source.In the present embodiment, CPU can also be set to take threshold
Value and EMS memory occupation threshold value etc., when concurrent thread exceedes certain amount, the cpu resource and memory source of occupancy exceed predetermined threshold value
When, concurrent thread quantity is adjusted, the system resource that downloading task takes is reduced so that other tasks there can be the system money of abundance
Source ensures its normal work.
In one embodiment, method also includes:When whether the downloading task of all threads is complete, by all texts
Part fragment combination is into file destination.
In the present embodiment, each thread only understands a part for downloading object file, when all threads downloading task all
When having completed, then show that all fragments of the file destination have all been downloaded to locally, to expect complete file, in addition it is also necessary to
All Files fragment combination is got up.
In one embodiment, there is provided a kind of side of multithreading downloading process thread regulating and controlling of quantities as shown in Figure 3
Method, comprises the following steps:
Step 301, thread is increased.
Step 302, under judging whether increase the speed of download after thread is more than before increase thread after preset time
Speed is carried, if so, then entering step 303, if it is not, then entering step 304.
Step 303, whether judge to increase the speed of download after thread not less than default speed of download threshold value, if so, then returning
Step 301 is returned, if it is not, then entering step 304.
Step 304, thread is reduced.
Step 305, under judging whether reduce the speed of download after thread is more than before reduction thread after preset time
Speed is carried, if so, then entering step 306, if it is not, then return to step 301.
Step 306, whether judge to reduce the speed of download after thread not less than default speed of download threshold value, if so, then returning
Step 304 is returned, if it is not, then return to step 301.
In the present embodiment, it is whether the speed of download for first judging to increase and decrease after thread is more than the download speed before increase and decrease thread
Whether degree, still first judge to increase and decrease the speed of download after thread not less than default speed of download threshold value, whole thread controlled
Process be do not have it is influential.Increase or decrease every time after thread, speed of download may change, and the change of speed of download
Need to can be only achieved stabilization after certain time, detect that its is downloaded after number of threads immediately if increased or decreased every time
Speed, obtained speed of download may not be really to increase or decrease the speed of download after thread, and confidence level is very low, directly
Very big error occurs for comparing, so needing after thread is increased or decreased, starts to compare speed again by preset time
Change.And the speed of download in downloading process is too fast, occupied bandwidth is excessive, it is most likely that can make some other tasks without
Method normal work, so needing to set a speed of download threshold value, makes speed of download keep maximum and is no more than speed of download threshold
The state of value, makes full use of bandwidth and does not interfere with the normal work of other tasks.
After a thread regulation process is completed, it can circulate and perform this process, enable number of threads with environment
Change is always maintained at speed of download closest to speed of download threshold value.But environmental change needs certain time, one is completed
After thread regulation and control, obtained number of threads ensure that within a certain period of time makes full use of bandwidth and as far as possible reduction system resource
Consumption.So, after a thread regulation and control are completed, the mistake of execution thread regulation and control can be started the cycle over again after preset time
Journey, it is ensured that after a time thread regulation and control of completion, obtained number of threads ensures making full use of and most for bandwidth within a period of time
Amount reduces the expense of system resource, is avoided that because circulation execution thread regulation process causes number of threads to be always maintained at download
Speed is maximum.
In the present embodiment, multiple threads can be increased and decreased every time, can also only increase and decrease a thread, due to increasing and decreasing multiple lines
Journey can make the process of thread regulation and control faster, and increasing and decreasing a thread can make the process of thread regulation and control more accurate, so can
, can when first pass adjusts number of threads, first to increase and decrease multiple threads, only increase and decrease a thread again during following cycle
The process for regulating and controlling thread is not only fast but also accurate.
In the present embodiment, by adjusting number of threads according to the change of speed of download, remain closest to speed of download
The default state for downloading threshold value, the bandwidth that system can be made full use of to distribute, and system resources consumption is reduced as far as possible.
As shown in figure 4, in one embodiment there is provided a kind of multithreading download apparatus, the device is specifically included:Download
Module 402, for receiving download instruction, is carried out according to the thread that download instruction opens default concurrent thread quantity to file destination
Download.
Thread control module 404, in downloading process, increasing or decreasing thread, every time after increase thread, if increase
Speed of download after thread is more than the speed of download before increase thread, then continues to increase thread, otherwise reduce thread;Reduce every time
After thread, if reducing the speed of download after thread is more than the speed of download before reducing, continues to reduce thread, otherwise increase line
Journey.
In one embodiment, multithreading download apparatus also includes:
Thread setup module 401, for receiving download instruction, the thread of predetermined number is opened to mesh according to download instruction
Before mark file is downloaded, network type is obtained, corresponding default concurrent thread quantity is set according to network type.
In one embodiment, thread control module 404, in downloading process, increasing or decreasing thread, increase every time
After ledger line journey, the speed of download after preset time starts to compare increase thread and the speed of download before increase thread, if increasing
Speed of download after ledger line journey is more than the speed of download before increase thread, then continues to increase thread, otherwise reduce thread;Subtract every time
After few thread, start to compare the speed of download after reducing thread and the speed of download before reduction thread by preset time, if subtracting
Speed of download after few thread is more than the speed of download reduced before thread, then continues to reduce thread, otherwise increase thread.
In one embodiment, thread control module 404, are additionally operable in downloading process, increase or decrease thread, every time
Increase after thread, if the speed of download after increase thread is more than the download after the speed of download before increase thread, and increase thread
Speed then continues to increase thread, otherwise reduces thread not less than default speed of download threshold value;Reduce every time after thread, if reducing
Speed of download after thread is more than the speed of download reduced before thread, and reduces the speed of download after thread not less than default download
Threshold speed, then continue to reduce thread, otherwise increase thread.
In one embodiment, multithreading download apparatus also includes:
File combination module 406, for when the downloading task of all threads is complete, by All Files fragment combination
Into file destination.
In one embodiment, as shown in Figure 5 there is provided a kind of multithreading download apparatus, the device specifically includes following
Module:
Thread setup module 401, for receiving download instruction, the thread of default ordered series of numbers is opened to mesh according to download instruction
Before mark file is downloaded, network type is obtained, corresponding default concurrent thread quantity is set according to network type.
Download module 402, for receiving download instruction, the thread pair of default concurrent thread quantity is opened according to download instruction
File destination is downloaded.
Thread control module 404, in downloading process, increasing or decreasing thread, every time after increase thread, by pre-
If the time starts to compare the download after the speed of download after increase thread and the speed of download before increase thread, such as Ou Zengjia threads
Speed is more than the speed of download before increase thread, and not less than default speed of download threshold value, then continues early more thread, otherwise
Reduce thread;Reduce every time after thread, start to compare the speed of download after reducing thread by preset time and reduce before thread
Speed of download, if reduce thread after speed of download be more than reduce thread before speed of download, and not less than it is default download speed
Threshold value is spent, then continues to reduce thread, otherwise increases thread.
File combination module 406, for when the downloading task of all threads is complete, by All Files fragment combination
Into file destination.
Each technical characteristic of embodiment described above can be combined arbitrarily, to make description succinct, not to above-mentioned reality
Apply all possible combination of each technical characteristic in example to be all described, as long as however, the combination of these technical characteristics is not deposited
In contradiction, the scope of this specification record is all considered to be.
Embodiment described above only expresses the several embodiments of the present invention, and it describes more specific and detailed, but simultaneously
Can not therefore it be construed as limiting the scope of the patent.It should be pointed out that coming for one of ordinary skill in the art
Say, without departing from the inventive concept of the premise, various modifications and improvements can be made, these belong to the protection of the present invention
Scope.Therefore, the protection domain of patent of the present invention should be determined by the appended claims.
Claims (10)
1. a kind of multithreading method for down loading, it is characterised in that including:
Download instruction is received, under the thread for opening default concurrent thread quantity according to the download instruction is carried out to file destination
Carry;
Performed during download:Thread is increased or decreased, every time after increase thread, if the speed of download after increase thread is big
Speed of download before increase thread, then continue to increase thread, otherwise reduce thread;Reduce every time after thread, if reducing thread
Speed of download afterwards is more than the speed of download reduced before thread, then continues to reduce thread, otherwise increase thread.
2. according to the method described in claim 1, it is characterised in that in the reception download instruction, according to the download instruction
Before the thread of unlatching predetermined number is downloaded to the file destination, in addition to:
Network type is obtained, corresponding default concurrent thread quantity is set according to the network type.
3. according to the method described in claim 1, it is characterised in that after each increase thread, if under after increase thread
The speed of download that speed is more than before increase thread is carried, then continues to increase thread, otherwise reduces thread, including:
Every time after increase thread, the speed of download after preset time starts to compare increase thread and the download before increase thread
Speed, if the speed of download after increase thread is more than the speed of download before increase thread, continues to increase thread, otherwise reduces line
Journey;
After each reduction thread, if reducing the speed of download after thread is more than the speed of download reduced before thread, continue
Thread is reduced, otherwise increases thread, including:
Reduce every time after thread, start to compare the speed of download after reducing thread and the download before reduction thread by preset time
Speed, if reducing the speed of download after thread is more than the speed of download reduced before thread, continues to reduce thread, otherwise increases line
Journey.
4. the method according to claim 1 or 3, it is characterised in that after each increase thread, if after increase thread
Speed of download is more than the speed of download before increase thread, then continues to increase thread, otherwise reduce thread, including:
Every time after increase thread, if the speed of download after increase thread is more than the speed of download before increase thread, and increase thread
Speed of download afterwards then continues to increase thread, otherwise reduces thread not less than default speed of download threshold value;
After each reduction thread, if reducing the speed of download after thread is more than the speed of download reduced before thread, continue
Thread is reduced, otherwise increases thread, including:
Reduce every time after thread, if reducing the speed of download after thread is more than the speed of download reduced before thread, and reduce thread
Speed of download afterwards then continues to reduce thread, otherwise increases thread not less than default speed of download threshold value.
5. according to the method described in claim 1, it is characterised in that methods described also includes:
When the downloading task of all threads is complete, by All Files fragment combination into the file destination.
6. a kind of multithreading download apparatus, it is characterised in that described device includes:
Download module, for receiving download instruction, the thread of default concurrent thread quantity is opened to institute according to the download instruction
File destination is stated to be downloaded;
Thread control module, in downloading process, increasing or decreasing thread, every time after increase thread, if after increase thread
Speed of download be more than increase thread before speed of download, then continue increase thread, otherwise reduce thread;Thread is reduced every time
Afterwards, if reducing the speed of download after thread is more than the speed of download before reducing, continue to reduce thread, otherwise increase thread.
7. device according to claim 6, it is characterised in that also include:
Thread setup module, for receiving download instruction, the thread of predetermined number is opened to described according to the download instruction
Before file destination is downloaded, network type is obtained, corresponding default concurrent thread quantity is set according to the network type.
8. device according to claim 6, it is characterised in that the thread control module is used in downloading process, increases
Add deduct few thread, every time after increase thread, speed of download and increase line after preset time starts to compare increase thread
The speed of download of Cheng Qian, if the speed of download after increase thread is more than the speed of download before increase thread, continues to increase thread,
Otherwise thread is reduced;
The thread control module is additionally operable to reduce after thread every time, starts to compare the download after reducing thread by preset time
Speed is with reducing the speed of download before thread, if reducing the speed of download after thread is more than the speed of download reduced before thread,
Continue to reduce thread, otherwise increase thread.
9. the device according to claim 6 or 8, it is characterised in that the thread control module is additionally operable in downloading process
In, thread is increased or decreased, every time after increase thread, if the speed of download after increase thread is more than the download speed before increase thread
Speed of download after degree, and increase thread then continues to increase thread, otherwise reduces thread not less than default speed of download threshold value;
The thread control module is additionally operable to reduce after thread every time, is reduced if reducing the speed of download after thread and being more than before thread
Speed of download, and reduce the speed of download after thread and continue to reduce thread not less than default speed of download threshold value, then, otherwise increase
Ledger line journey.
10. device according to claim 6, it is characterised in that described device also includes:
File combination module, for when the downloading task of all threads is complete, by All Files fragment combination into described
File destination.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610908996.5A CN106998349A (en) | 2016-10-18 | 2016-10-18 | Multithreading method for down loading and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610908996.5A CN106998349A (en) | 2016-10-18 | 2016-10-18 | Multithreading method for down loading and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106998349A true CN106998349A (en) | 2017-08-01 |
Family
ID=59431829
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610908996.5A Pending CN106998349A (en) | 2016-10-18 | 2016-10-18 | Multithreading method for down loading and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106998349A (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109144699A (en) * | 2018-08-31 | 2019-01-04 | 阿里巴巴集团控股有限公司 | Distributed task dispatching method, apparatus and system |
CN109753849A (en) * | 2017-11-03 | 2019-05-14 | 杭州海康威视数字技术股份有限公司 | The method and apparatus for handling video analytic tasks |
CN110247815A (en) * | 2019-05-09 | 2019-09-17 | 深圳市迅雷网络技术有限公司 | A kind of data transmission method, device, system and computer readable storage medium |
WO2020026018A1 (en) * | 2018-07-31 | 2020-02-06 | 优视科技新加坡有限公司 | Method for downloading file, device, apparatus/terminal/ server, and storage medium |
CN112055036A (en) * | 2019-06-05 | 2020-12-08 | 阿里巴巴集团控股有限公司 | Data downloading method, device, equipment, system and readable storage medium |
CN112422632A (en) * | 2020-10-26 | 2021-02-26 | 京东方科技集团股份有限公司 | File uploading control method and device, electronic equipment and storage medium |
CN113556408A (en) * | 2021-09-23 | 2021-10-26 | 统信软件技术有限公司 | Task downloading method and device, computing equipment and storage medium |
CN114338657A (en) * | 2022-03-15 | 2022-04-12 | 北京搜狐新动力信息技术有限公司 | Video file downloading method and device, electronic equipment and storage medium |
EP4009643A1 (en) * | 2020-12-03 | 2022-06-08 | Hulu, LLC | Concurrent downloading of video |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101730086A (en) * | 2009-12-02 | 2010-06-09 | 北京盈通创新数字技术有限公司 | High speed downloading method of mobile terminal connecting multiple gateways and starting multiple threads |
CN101945082A (en) * | 2009-07-09 | 2011-01-12 | 联想(北京)有限公司 | Method for automatically adjusting network downloading speed and network downloading equipment thereof |
CN105791985A (en) * | 2014-12-22 | 2016-07-20 | 深圳Tcl数字技术有限公司 | Media stream data downloading method and device |
CN105791254A (en) * | 2014-12-26 | 2016-07-20 | 阿里巴巴集团控股有限公司 | Network request processing method, device and terminal |
-
2016
- 2016-10-18 CN CN201610908996.5A patent/CN106998349A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101945082A (en) * | 2009-07-09 | 2011-01-12 | 联想(北京)有限公司 | Method for automatically adjusting network downloading speed and network downloading equipment thereof |
CN101730086A (en) * | 2009-12-02 | 2010-06-09 | 北京盈通创新数字技术有限公司 | High speed downloading method of mobile terminal connecting multiple gateways and starting multiple threads |
CN105791985A (en) * | 2014-12-22 | 2016-07-20 | 深圳Tcl数字技术有限公司 | Media stream data downloading method and device |
CN105791254A (en) * | 2014-12-26 | 2016-07-20 | 阿里巴巴集团控股有限公司 | Network request processing method, device and terminal |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109753849A (en) * | 2017-11-03 | 2019-05-14 | 杭州海康威视数字技术股份有限公司 | The method and apparatus for handling video analytic tasks |
WO2020026018A1 (en) * | 2018-07-31 | 2020-02-06 | 优视科技新加坡有限公司 | Method for downloading file, device, apparatus/terminal/ server, and storage medium |
CN109144699A (en) * | 2018-08-31 | 2019-01-04 | 阿里巴巴集团控股有限公司 | Distributed task dispatching method, apparatus and system |
CN110247815A (en) * | 2019-05-09 | 2019-09-17 | 深圳市迅雷网络技术有限公司 | A kind of data transmission method, device, system and computer readable storage medium |
CN112055036A (en) * | 2019-06-05 | 2020-12-08 | 阿里巴巴集团控股有限公司 | Data downloading method, device, equipment, system and readable storage medium |
CN112422632A (en) * | 2020-10-26 | 2021-02-26 | 京东方科技集团股份有限公司 | File uploading control method and device, electronic equipment and storage medium |
CN112422632B (en) * | 2020-10-26 | 2023-09-12 | 京东方科技集团股份有限公司 | File uploading control method and device, electronic equipment and storage medium |
EP4009643A1 (en) * | 2020-12-03 | 2022-06-08 | Hulu, LLC | Concurrent downloading of video |
US11570496B2 (en) | 2020-12-03 | 2023-01-31 | Hulu, LLC | Concurrent downloading of video |
CN114500483A (en) * | 2021-09-23 | 2022-05-13 | 统信软件技术有限公司 | Task downloading method and device, computing equipment and storage medium |
CN113556408A (en) * | 2021-09-23 | 2021-10-26 | 统信软件技术有限公司 | Task downloading method and device, computing equipment and storage medium |
CN114500483B (en) * | 2021-09-23 | 2024-02-27 | 统信软件技术有限公司 | Task downloading method and device, computing equipment and storage medium |
CN114338657A (en) * | 2022-03-15 | 2022-04-12 | 北京搜狐新动力信息技术有限公司 | Video file downloading method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106998349A (en) | Multithreading method for down loading and device | |
US9083637B2 (en) | System and method for providing dynamic QoS to maximize bandwidth utilization | |
US10069683B2 (en) | Apparatus for optimising a configuration of a communications network device | |
CN110248417B (en) | Resource allocation method and system for communication service in power Internet of things | |
US20210067417A1 (en) | Methods, systems and appratuses for optimizing the bin selection of a network scheduling and configuration tool (nst) by bin allocation, demand prediction and machine learning | |
US10917355B1 (en) | Methods, systems and apparatuses for optimizing time-triggered ethernet (TTE) network scheduling by using a directional search for bin selection | |
CN109905329B (en) | Task type aware flow queue self-adaptive management method in virtualization environment | |
CN105873022A (en) | Downloading method and device for mobile terminal | |
CN104243332A (en) | Sub-channel application flow control method based on DPI identification | |
CN106997351B (en) | Resource cache management method, system and device | |
CN105553882B (en) | Method for the scheduling of SDN data-plane resources | |
CN106716368B (en) | Network classification for applications | |
CN107395521B (en) | Big data information processing method and system based on Internet of things | |
CN112667407A (en) | Processor parameter adjusting method and device, electronic equipment and storage medium | |
CN110674942A (en) | Bandwidth management method and device, electronic equipment and readable storage medium | |
CN113098724A (en) | Server tuning method, system and device | |
CN115766592A (en) | Flow rate limiting method based on priority, DPU message forwarding method and device | |
CN105306385B (en) | The control method and device of downlink network bandwidth | |
CN110691039A (en) | Satellite-borne multichannel multi-terminal self-adaptive scheduling method and system | |
CN107239345A (en) | Data processing method and device | |
CN105636224A (en) | Network resource optimization method and device and wireless access point | |
CN106231613B (en) | Distribution strategy generation method and device and network optimization system | |
US11343189B2 (en) | Systems and methods for augmenting TCAM bank processing with exact match | |
CN105915360A (en) | Method for adjusting equipment network speed on router and device and system thereof | |
CN107864515A (en) | A kind of control method and device of AP channels switching |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170801 |