通过 iPhone 从单一来源进行多个下载线程

发布于 2024-09-06 19:58:04 字数 87 浏览 6 评论 0原文

我在从一台服务器下载 5 个不同的文件时遇到问题。是否可以通过 5 个单独的线程从该服务器下载所有 5 个文件?如果是,这比通过单线程依次下载每个文件是否有效?

I have a problem of downloading 5 different files from a single server. Is that possible to download all 5 files from that server over 5 individual threads ? If yes, is that efficient than downloading each file one after another via single thread ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遇见了你 2024-09-13 19:58:04

通过单独的线程下载文件总是更有效。如果您通过主线程下载它们,这只会阻塞主线程,并且您的应用程序在下载过程中会冻结一会儿。我建议,如果您要下载大量文件,请查看 MBProgressHUD 库,这是一个非常好的向用户传达下载进度的方式。

It is always more efficient to download files via separate threads. If you download them via the main thread, this will simply block the main thread and it will appear that your app has frozen for a moment while the downloads are taking place. I would suggest that if you are downloading a large number of files, look into the MBProgressHUD library which is an excellent way of communicating the downloads' progress to your users.

北风几吹夏 2024-09-13 19:58:04

假设您此时正在从辅助线程下载:

是的。 5 个并发下载就可以了,并且最终可以减少完成所有 5 个请求所需的时间(实际上)。但是,您应该将并发下载数量保持在相对较低的水平 - 不要尝试同时运行 30 个,而是创建一个队列。

确定下载的优先级也很好,并在需要以更高优先级下载某些内容时添加暂停。

assuming you're downloading from secondary threads at this time:

yes. 5 concurrent downloads is fine, and can ultimately decrease the time it takes to complete all 5 requests (in practice). however, you should keep the number of concurrent downloads relatively low - don't try to run 30 at the same time, but create a queue.

it's also good to prioritize your downloads, and add suspension for times when you need something downloaded at a higher priority.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文