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 8670741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:46:45+00:00 2026-06-12T18:46:45+00:00

I want to start two Async Tasks but the second will not start until

  • 0

I want to start two Async Tasks but the second will not start until the first has completed.

From what I’ve googled, people usually suggest this approach:

new MyAsyncTask().execute(params);
new MyAsyncTask().execute(params);

However, I need to instantiate them separately and also keep the handles of the task’s (to pass messages for example). Therefore, I SORT OF do this:

onStart() 
{
  taskA = new MyAsyncTask(paramsA);
  taskB = new MyAsyncTask(paramsB);
}

onButtonPress()
{
  taskA.execute();
  taskB.execute();
}

Edit:
I’ve noticed that taskB does not actually start executing until taskA completes (which runs a tcp/ip server so it takes a long time). I cannot figure out why. Any thoughts or comments ?

  • 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-12T18:46:46+00:00Added an answer on June 12, 2026 at 6:46 pm

    The short answer is that, depending on your version of Android, all AsyncTask subclasses may be using the same thread, so you can only do one at a time. There are two ways around this:

    1. Use Runnable instead of AsyncTask
    2. Replace one call to execute with executeOnExecutor(Executor.THREAD_POOL_EXECUTOR, params)

    Clearly, try #2 first – it’s less of a code change. But if that doesn’t work pretty quickly, I’d switch to #1. In that case, you don’t have to worry about how Android might change in the future.

    If you want more details about the threading model for AsyncTask, have a look at the Android doc entry.

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

Sidebar

Related Questions

Hey everyone, I want to start using Scheme and I have two questions. First,
So I want to position an element across two columns, but only start in
When using GCD, we want to wait until two async blocks are executed and
I want to start several threads, retrive data from net, perform some actions with
I want to start a calculation task that will last for a couple of
I want to start some large project. There are two technologies that i can
I have say two threads t1 and t2 which I want to start at
I want to start my journey with JavaScriptMVC, but I really don't know how
I am trying to start a Service from my PreferenceActivity. I want to start
I want to send one of two async requests based on a click event

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.