Run Multiple AsyncTask at the same time

Android Run Multiple AsyncTask Same Time

Problem:
I am trying to excute Multiple asynctask same time(Android Version 4.0.1) but onPreExcute method only called  after that nothing happen.

Solution.
AsyncTask uses a thread pool pattern for running the stuff from doInBackground(). The issue is initially (in early Android OS versions) the pool size was just 1, meaning no parallel computations for a bunch of AsyncTasks. But later they fixed that and now the size is 5, so at most 5 AsyncTasks can run simultaneously. 

--> 
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

TestAsyncTask firstAsync = new TestAsyncTask();

firstAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);


}

else{

TestAsyncTask firstAsync = new TestAsyncTask();

firstAsync.execute();


}

Comments

Popular posts from this blog

Android Objective type Question and Answers

Android Questions and Answers for written exams

Core Java -----Question and Answers