Tuesday, December 4, 2012

Android Run Multiple AsyncTask 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();


}

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...