In my android application, I have to get almost 50 data (50 AsyncTask
) from server parallel y. So I implemented my logic by using executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
. And I read about executeOnExecutor
which can run only 5 AsyncTask
at a time and it has a queue of size 10. Where we can keep maximum 10 pending AyncTask
. Ok, now in my scenario I have 50 AsyncTask
and I can't execute 50 AsyncTask
together parallel y because the queue have size only 10. So I can't go with approach of executing 50 AsyncTask
together.
So I came up with an other logic, there I will create and execute 5 AyncTask
together. And I will start new AysncTask
on call back of each already executed AsyncTask
.
The second logic satisfied my requirement. It is working perfectly.
Note: Here I'm using my own AsyncTask
class and I'm making http request by using Apache http client.
Now, newly I heard about a library called android-async-http. I wanted to reimplement the above logic with this library.
Sample code:
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://www.google.com", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
System.out.println(response);
}
});
So my question is,
How do I execute http request parallel y by using android-async-http library?
What is the maximum number of
AsyncTask
I can execute parallel y by using this library?