登录
首页 » Windows Socket编程 »  各个线程任务分配是这样实现的。在开始下载时,文件平均分成若干块进行下载。如第一个线程一开始的任务是从文件的0位置开始下载一直到72908位置处。线程1每次下载...

 各个线程任务分配是这样实现的。在开始下载时,文件平均分成若干块进行下载。如第一个线程一开始的任务是从文件的0位置开始下载一直到72908位置处。线程1每次下载...

于 2022-03-20 发布 文件大小:93.98 kB
0 238
下载积分: 2 下载次数: 1

代码说明:

 各个线程任务分配是这样实现的。在开始下载时,文件平均分成若干块进行下载。如第一个线程一开始的任务是从文件的0位置开始下载一直到72908位置处。线程1每次下载一块数据后就要调整任务,如第一次下载了20800字节的数据,那么线程1的任务将改为:20800-72908。如此下去,直到任务为72908-72908时表示线程1完成了当前的下载任务。此时,线程1就分析各个线程的任务,找出任务最为繁忙的一个线程:如线程3:14816-218724。那么线程1就自动去调整任务,拿50%的任务来再次下载。周而复始直到各个线程都完成任务。不过这里有一点需要注意:为了避免重复下载部分数据,在调整任务的时候,起始的文件便移量必须加上接受缓冲器的字节数,因为如前面所举的列子来看。线程1和线程3在平衡负载的时候,线程正在下载数据,如果所剩的数据比接受缓冲器的大小还小,线程1和线程3的部分下载数据将会重复。   在调整任务和分析任务的时候,会发现一个问题。就是读取文件数据太过频繁。于是我用了一个数据结构。在下载文件的过程中始终打开配置文件,这样速度提高了很多。在文件下载完毕后关闭文件。-various threads assignment is achieved. At the beginning of the download, the paper divided into a number of pieces of the download. As a thread of a task is to start from the position paper of 0 to start the download has 72,908 locations Department. Thread a download each one will have to adjust the data tasks, such as the first downloaded 20,800 gigabytes of data, then threaded a task will be re :20800- 72908. This situation continues until the mandate of 72908-72908 said threaded a completion of the cu

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • php template technology, using technology smarty official php web template devel...
    php 模板 技术实现, 采用 smarty 官方技术实现 php web 模板开发, 几秒钟实现全站更新-php template technology, using technology smarty official php web template development, a few seconds to realize the station update
    2022-01-25 20:21:03下载
    积分:1
  • 用visual c++开发的模拟小球动画的
    用visual c++开发的模拟小球动画的程序-Using visual c++ Developed simulation procedures for the ball animation
    2022-05-16 18:54:53下载
    积分:1
  • lan中的端口映射
    lan中的端口映射程序-the port mapping procedures
    2023-01-30 05:30:03下载
    积分:1
  • 存量房
    股票实时数据控件是标准的OCX控件,提供实时的沪深股票数据,数据来自各种数据接口,如银江、数畅等。股票实时数据控件是国内第一款股票数据的ocx控件,可以用在支持Activex的所有语言上。-Stock real-time data control is a standard OCX control, Shanghai and Shenzhen to provide real-time stock data, data from a variety of data interfaces, such as the Silver River, a few smooth and so on. Stock real-time data control is China" s first stock data, ocx control, can be used in support of Activex in all language.
    2023-01-06 13:50:03下载
    积分:1
  • 一个单班级的同学录系统,还比较好用的,试用于,网站建设...
    一个单班级的同学录系统,还比较好用的,试用于,网站建设-a single-class college system, but also more useful, and use it on site construction
    2022-11-09 23:05:03下载
    积分:1
  • This is a time for the correction of the source from the online collection from
    这是一个基于时间的校正的源程序 由网上收集而来-This is a time for the correction of the source from the online collection from
    2023-08-29 07:45:03下载
    积分:1
  • By infrared usb virtual serial port to a small program, and have read the attach...
    经usb红外口转为虚拟串口的小程序,并且附带有读取程序。-By infrared usb virtual serial port to a small program, and have read the attached program.
    2023-08-31 06:55:04下载
    积分:1
  • IE Programming simple example of the realization of the browser [] to delete IE...
    IE编程实例 简单的浏览器的实现【chap4MyBrowser】 删除IE相关历史记录【chap4DelHistory】 将应用程序加入到IE工具栏【chap4AddToToolBar】 超级链接的实现【chap4HyperLink】 禁止IE的弹出窗口【chap4StopPopup】 禁止浏览某些网站【chap4StopTravel】 IE收藏夹【chap4 MyBrowser】 创建桌面快捷方式和活动桌面【chap4ShortCut】-IE Programming simple example of the realization of the browser [] to delete IE related chap4MyBrowser history] [chap4DelHistory application added to the IE toolbar chap4AddToToolBar] [hyperlinks realization chap4HyperLink] [Prohibition of IE pop-up window] [chap4StopPopup prohibited browser Some sites chap4StopTravel] [IE Favorites] [chap4 MyBrowser create desktop shortcuts, and Active Desktop chap4ShortCut []
    2022-05-29 09:24:34下载
    积分:1
  • flsah素材源码
    flsah素材源码-人物图案系列02 人物图案系列02 -flsah source material-figure logo Series 02 figures pictorial series 02 Series 02 figures pictorial characters pictorial series 02 Series 02 figures pictorial characters logo Series 02
    2022-03-25 18:08:03下载
    积分:1
  • 自动备份,可配置服务器信息。 采用TCP
    远程自动备份,可配置服务器信息。 采用TCP-WINSOCK多线程实现,可以多对多备份。-Remote automatic backup allows you to configure the server information. Using TCP-WINSOCK realize multi-threaded, you can back up many-to-many.
    2022-05-26 15:03:37下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载