Skip to content Skip to sidebar Skip to footer

Execution Order In Asynctask Inside Loop

I have a problem concerning execution order.I get some data from server ( cities names , LatLng) and on onPostExecute i'm trying to calculate distances between cities. During last

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"