Like Android 3+, AsyncTasks will execute sequentially on AsyncTask.SERIAL_EXECUTOR . Therefore, by default, if you run 2 AsyncTasks
task1.execute(); task2.execute();
Task2 will only be executed if task1 is complete (just check the sdk implementation of AsyncTask.SERIAL_EXECUTOR ). This can be done so that if task 1 never ends for any reason, task2 will never start and you have blocked your application.
If you want your own queue not to depend on the standard SERIAL_EXECUTOR, just use
public final AsyncTask<Params, Progress, Result> executeOnExecutor (Executor exec, Params... params)
And provide your own artist (aka threadpool). For one project, I copied the implementation of SERIAL_EXECUTOR to have 2 consecutive queues.
For Android from 2.3 to 1.6, all tasks are parallel by default, similar to calls in Android 3+:
task.executeOnExecutor (AsyncTask.THREAD_POOL_EXECUTOR, NULL);
Unfortunately, in Android 2.3 and below you have no way to specify the artist on which the task / thread will be launched. Therefore, if you want this done sequentially, you must implement it yourself by calling task2 only after task1 has finished explicitly in onPostExecute() . Of course, this concept can be used for a task queue, where the first task will call the next one when it finishes (= ordinal queue of workers). For this you will find a lot of literature and patterns.
source share