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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:44:06+00:00 2026-05-31T02:44:06+00:00

I have a few lines of code that I want to run asynchronously in

  • 0

I have a few lines of code that I want to run asynchronously in Javascript so that it doesn’t slow down my main algorithm. See this pseudo code:

//main algorithm with critical code that should run as soon as possible
...
...
runInParallel(function(){
  //time consuming unimportant code to shows some progress feedback to user
  ...
}
//the rest of the time critical algorithm
...
...
runInParallel(function(){
  //time consuming unimportant code to shows some progress feedback to user
  ...
}
//and so on and so forth

I searched Stackoverflow for how to write asynchronous code in Javascript but the following questions are not similar to mine:

  • how to run a javascript function asynchronously, without using setTimeout?: it’s about server side
  • Loading javascript asynchronously – How to do callbacks?: it’s about loading source code

I guess I can use timers for this purpose. All I want is the body of the function runInParallel() that runs a code efficiently in parallel with my main algorithm with lower priority if possible. Anyone?

  • 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-31T02:44:08+00:00Added an answer on May 31, 2026 at 2:44 am

    Javascript has no synchronization / thread management. If you wish to execute something asynchronously, you can use setTimeout combined with a callback to be notified when the function ‘s finished.

     var asyncHandle = setTimeout(function () { asyncCode(); callback(); }, 10);
    

    The asyncHandle can be used to cancel the timeout prior to the function being called.

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

Sidebar

Related Questions

I have written a few lines of code in Python to see if I
i have this few lines of code FilterCondition CustomerID = new FilterCondition(Customer_ID,cust.Customer_ID,FilterCondition.FilterOperator.Equals); List<FilterCondition> conditions
I have this line of code: System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shinfo.hIcon); A few lines later,
I have a sample.xhtml file which has few lines of javascript. This javascript will
I want to run some lines of applescript code from within my application. The
I have been fiddling with a few lines of code for two days now
I have the first few lines of a text file fx.txt with the following
I have DIV element which only has a few lines in and a background
I have a text file with few first few lines not required and then
I have the following regular expression with which I match a few lines. Here

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.