Reputation: 5696
I have the same problem Running multiple AsyncTasks at the same time -- not possible? except I use android 4.0 with android:minSdkVersion="14".
I tried his example, and get also :
bar bar bar
bar bar bar
bar bar bar
EDIT :
I found the solution here
Instead of using :
task.execute();
use :
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null);
Upvotes: 7
Views: 4468
Reputation: 3327
Sounds like this explains it (from the documentation):
When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with HONEYCOMB, tasks are executed on a single thread to avoid common application errors caused by parallel execution.
If you truly want parallel execution, you can invoke executeOnExecutor(java.util.concurrent.Executor, Object[]) with THREAD_POOL_EXECUTOR.
Upvotes: 5