Re: [android-developers] Simultaneous Http Requests
Nathan 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.
IMHO, just use AsyncTask for the HTTP requests. It already has a thread
pool, tuned for what the core Android team feels is a reasonable number
of threads for this sort of purpose.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Android Consulting/App Development: http://commonsware.com/consulting
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home