views:

19

answers:

2

Hi,

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 ?

A: 

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.

Jason
A: 

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.

Justin