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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:32:49+00:00 2026-05-27T18:32:49+00:00

For example, lets say I make a function called foobar, and inside foobar are

  • 0

For example, lets say I make a function called “foobar”, and inside foobar are calls to asynchronous functions. For example, it might look like this:

function foobar() {
    // asynchronous function here.
    // asynchronous function here.
}

Now, if I call foobar() five times like this:

foobar();
foobar();
foobar();
foobar();
foobar();

Will it only fire two asynchronous functions at a time?

  • 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-05-27T18:32:49+00:00Added an answer on May 27, 2026 at 6:32 pm

    No, it will fire all 10. It will fire the first two (asynchronously), then the single Javascript thread will return from the first call and enter the second one, call two more etc. Until all 10 have been called. Example:

    var i = 0;
    function foobar(){
        // Execute functions asynchronously by using setTimeout
        setTimeout(function(){ alert(++i); }, 0);
        setTimeout(function(){ alert(--i); }, 0);
    }
    
    foobar();
    foobar();
    foobar();
    foobar();
    foobar();
    alert('This will ALWAYS alert first');
    

    The last alert will always alert first since Javascript is single threaded, after that the other alerts will occur in any order depending on scheduling. You may see any number between -5 and 5 alerted, but the last alert will always be 0.

    http://jsfiddle.net/Paulpro/uJd44/

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

Sidebar

Related Questions

For example, say im doing a limited query function like this: function getLogList() {
Lets say for example: $(.button).click(function() { $.post(commandrunner.php, { param1: 'value', param2: 'value2', param3: 'value3'
Let's say I have an event and the corresponding function is called. This function
To use as an example: lets say that I have 2 EditText s and
Here is my scenario. For the example lets say that I need to return
I want to put a conditional breakpoint in windbg. For example lets say LoadLibrary
How does CouchDB handles conflicts while doing bi-directional replication? For example: Lets say there
I have 2 websites, lets say - example.com and example1.com example.com has a database
Lets say I am currently at: http://example.com/folder/page.html Is it possible to create a relative
My simplified and contrived example is the following:- Lets say that I want to

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.