Hi all,
I am struck with an interesting problem.
I have a listview with 30 items which contains an image (from a web
server) and a text.
So, when I load pictures, I start a new thread with the AsyncTask
class to do not block the UI thread.
But, if I have more than 20 threads at the same times, I have a
RejectedExecutionException from the ThreadPoolExecutor.
To resume, I have simplify my code, for example:
for (int i = 0; i < 21; i++) {
new DownloadImageTask().execute("Test");
}
private class DownloadImageTask extends AsyncTask<String, Integer,
Bitmap> {
public DownloadImageTask() {
super();
}
@Override
protected Bitmap doInBackground(String... urls) {
try {
System.out.println("execute");
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Bitmap result) {
}
}
So, I think we can run 10 thread max and we have a pool of 10 thread
max.
Can someone help me understand if there are limits on AsyncTask? If we
can modify the number of maw thread execution and the number max of
the pool? Or other idea ?
Thanks
David
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---