First of all, AsyncTask
can be executed only on the UI thread. So, even if you have two separate handlers (one for each AsyncTask
) they should be both associated with the UI thread.
Secondary, several AsyncTask
instances may run either simultaneously or one by one. It depends on the API version. It is better to read documentation about this:
public final AsyncTask execute (Params... params)
Executes the task with the specified parameters.
The task returns itself (this) so that the caller can keep a reference
to it.
Note: this function schedules the task on a queue for a single
background thread or pool of threads depending on the platform
version. 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 HONEYCOMB, tasks are back to being executed on a single
thread to avoid common application errors caused by parallel
execution. If you truly want parallel execution, you can use the
executeOnExecutor(Executor, Params...) version of this method with
THREAD_POOL_EXECUTOR; however, see commentary there for warnings on
its use.