Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7891383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:36:19+00:00 2026-06-03T06:36:19+00:00

I want to know how AsyncTask works internally. I know it uses the Java

  • 0

I want to know how AsyncTask works internally.

I know it uses the Java Executor to perform the operations but still some of the questions I am not understanding. Like:

  1. How many AsyncTask can be started at a time in an Android app?
  2. When I start 10 AsyncTask, will all tasks will run simultaneously or one by one?

I have tried with 75000 AsyncTask to test the same. I don’t get any problem and seems like all the tasks will be pushed to stack and will run one by one.

Also when I start 100000 AsyncTasks, I start getting OutOfMemoryError.

So is there any limit of no of AsyncTask which can be run at a time?

Note: I have tested these on SDK 4.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:36:21+00:00Added an answer on June 3, 2026 at 6:36 am

    AsyncTask has a rather long story.

    When it first appeared in Cupcake (1.5) it handled background operations with a single additional thread (one by one). In Donut (1.6) it was changed, so that a pool of thread had begun to be used. And operations could be processed simultaneously until the pool had been exhausted. In such case operations were enqueued.

    Since Honeycomb default behavior is switched back to use of a single worker thread (one by one processing). But the new method (executeOnExecutor) is introduced to give you a possibility to run simultaneous tasks if you wish (there two different standard executors: SERIAL_EXECUTOR and THREAD_POOL_EXECUTOR).

    The way how tasks are enqueued also depends on what executor you use. In case of a parallel one you are restricted with a limit of 10 (new LinkedBlockingQueue<Runnable>(10)). In case of a serial one you are not limited (new ArrayDeque<Runnable>()).

    So the way your tasks are processed depends on how you run them and what SDK version you run them on.
    As for thread limits, we are not guaranteed with any, yet looking at the ICS source code we can say that number of threads in the pool can vary in range 5..128.

    When you start 100000 with default execute method serial executor is used.
    Since tasks that cannot be processed immediately are enqueued you get OutOfMemoryError (thousands of tasks are added to the array backed queue).

    Exact number of tasks you can start at once depends on the memory class of the device you are running on and, again, on executor you use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Want to know ways to store OBJECTS of a Class in some persistent storage.
I know there's already tons of similar questions, but I checked over twenty answers
It works just fine when I run it in a thread, but I want
I want to know if starting up a asynctask from a broadcast receiver considered
I use AsyncTask in several activities. i know how to Override onBackPress(). But when
I have an activity that uses AsyncTask to download and save some data to
i want know if is possible, to get a specific element value of a
I'm making a chat responder for a game and i want know if there
want to know why String behaves like value type while using ==. String s1
Want to know what is the difference between ipv4 and ipv6 and how does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.