Tuesday, February 24, 2015

Execute multiple asynctask at same time in android

AsyncTask empowers fitting and simple utilization of the UI string. This class permits to perform background operations and show results on the UI thread.

When we use AsyncTasks, than it only execute on a single background thread. Beginning with DONUT, this was changed to a pool of strings permitting numerous tasks to work in parallel. Beginning with HONEYCOMB, assignments are executed on a single string to stay away from regular application errors created by parallel execution.



AsyncClass async=new AsyncClass(;)


if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB)
{
                  async.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,"");

} else
{
async.execute(""); //execute serially
}

.execute   always execute a asynctask serially,which means one by one.
executeOnExecutor it works only in new versions ,above HONEYCOMB and by using executeOnExecutor  you can execute multipleasync task parallely ..

0 comments:

Post a Comment

Don't lose faith when you see others receive answers to their prayers

An elephant and a dog became pregnant at same time. Three months down the line the dog gave birth to six puppies. Six months later the dog...

 

G-Expo Template by Ipietoon Cute Blog Design