I have a very similar operation in my application.  Personally, the
user is using the downloaded files in some sort of sequential order,
so I do them one at a time in a single background thread.  To be
precise, I'm trying to transfer some metadata about the image (which
is in a database) as well as an image.  The HTTP request (I only do
one), provides an XML file detailing all the metadata / location of
each image.  Then, for each <Image> entry in the XML, I actually
download the .jpg using an FTP library, though i supposed your HTTP
would be almost identical.

Either way, I think spawning 20 threads sounds like a bad idea, even
if Android can handle the overhead, it is unlikely that it will be
useful for receiving your responses in a timely manner on a relatively
slow network.

On Jan 13, 3:12 pm, Nathan <[email protected]> wrote:
> Is there a limit on the number of simultaneous http requests of the
> form:
>
> HttpResponse response = client.execute(request);
>
> I'm interested in any official limit as well as practical ones.
>
> (In a previous life, you had to dig deep to discover that WinMo only
> allowed three WebRequests to be open at a time.)
>
> Let's say I have a list of 20 files to download on a background
> thread.
>
> Should I:
> Download them one at a time, blocking the thread (but not the UI
> thread) to wait for each one?
> Start 20 threads each downloading one of the files?
>
> I expect the answer may be somewhere in between, where I create C
> threads and work on the queue of N files, where C is a number like 3
> or 4.
>
> I suspect some of you here have already done some experimentation and
> know the magic number. In addition, I suspect there may be more
> efficient ways of doing what I'm doing than creating a new
> DefaultHttpClient for each request.
>
> Thanks for any insights.
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to