Execution Order In Asynctask Inside Loop
Solution 1:
Android Developers says:
When first introduced, AsyncTasks were executed serially on a single background thread. Starting with
{android.os.Build.VERSION_CODES#DONUT}
, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with{ android.os.Build.VERSION_CODES#HONEYCOMB}
, tasks are executed on a single thread to avoid common application errors caused by parallel execution.
Also since executor of AsyncTask
is static so you get single executor of your application.
Now it already running GetData asyncTask and it runs asynsTask serially so it cannot execute your DownloadTask
. It can run only after GetDataTask is finished.
If you want to run multiple asynctasks in parallel, you can look at Asynctask.executeOnExecutor()
.
Post a Comment for "Execution Order In Asynctask Inside Loop"