running parallel AsyncTask
Solution 1:
There has been a change in AsyncTask from Honeycomb release. Older versions had a Thread pool of 10 threads, so you could run 10 tasks in parallel. But for Honeycomb and up, default is a serial executor, which executes tasks one by one. But you can pass a ThreadPoolExecutor
for execution:
if (Build.VERSION.SDK_INT >= 11) {
//--post GB use serial executor by default --
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
//--GB uses ThreadPoolExecutor by default--
task.execute();
}
Solution 2:
You will need to use a thread pool Executor
to execute AsyncTask
. Default implementation uses a serial executor running on a single thread
So create a ThreadPoolExecutor and then use
AsyncTask's executeOnExecutor instead of just execute method