Quanturium
Quanturium

Reputation: 5696

Android 4.0 asynctask at the same time not possible

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

Answers (1)

Tobias Ritzau
Tobias Ritzau

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

Related Questions