-1

AsyncTask are executed seriallu but we can execute them parallely using executeOnExecutor. How many Asynctask we can execute parallely in Android?

user1800923
  • 11
  • 1
  • 1
  • 3
  • Possible duplicate of [How many AsyncTasks i can run in an single process application](http://stackoverflow.com/questions/24505981/how-many-asynctasks-i-can-run-in-an-single-process-application) – ישו אוהב אותך Oct 10 '16 at 07:13

3 Answers3

1

I believe this StackOverflow post has already answered your question: How many AsyncTasks i can run in an single process application

How many AsyncTasks can you run at once?

In most versions of Android, the answer is 128.

Please do a quick search before asking these questions.

Community
  • 1
  • 1
Rupayan Neogy
  • 73
  • 1
  • 10
0

Android uses ThreadPool inside AsyncTask. Maximum size of this thread pool is

MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1;

So maximum number of AysncTask depends on CPU Count.

Reference:

http://dsalgos.com/971/how-many-asynctasks-can-you-execute-in-parallel

Ashish Rathee
  • 449
  • 3
  • 16
  • 1
    Adding to this, you can also create your own executor, with your own settings. So with a custom executor, it can be theoretically unlimited. – Daniel Zolnai Oct 10 '16 at 06:38
0

Check this answer.

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. Unfortunately I don't remember in what version exactly they changed that.

Running multiple AsyncTasks at the same time -- not possible?

Also check the above link. Hope it will help.

Community
  • 1
  • 1
vidulaJ
  • 1,232
  • 1
  • 16
  • 31