7

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);
Community
  • 1
  • 1
Quanturium
  • 5,698
  • 2
  • 30
  • 36
  • Please consider adding your soulution as an answer and accept it so this question does not show up as unanswered anymore. I will upvote your answer if you do. – Dirk Jäckel Jun 21 '12 at 10:35

1 Answers1

5

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.

Tobias Ritzau
  • 3,327
  • 2
  • 18
  • 29
  • 2
    And with a code example, instead of calling `myAsyncExtendingClass().execute()`, you would call `myAsyncExtendingClass().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "");` – Dzhuneyt Nov 05 '12 at 14:46