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();


}

1 comment:

  1. Hello There. I discovered your weblog the usage of msn.
    That is an extremely neatly written article.

    I'll make sure to bookmark it and come back to read more of your helpful information. Thank you for the post. I will definitely comeback.
    Here is my homepage ... black diamond titanium rings

    ReplyDelete

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...