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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:02:29+00:00 2026-05-27T04:02:29+00:00

Yes I’m aware that asking for a formal memory model in Javascript is a

  • 0

Yes I’m aware that asking for a formal memory model in Javascript is a hopeless undertaking, so I’m settling for “All browsers follow these rules” or something.

My problem is the following: I have to send events in a defined interval to a server, but events may be added to my array while doing so, i.e.:

function storeEvent(event) {
    // may be called at any time
    storedEvents.push(event);
}

function broadcastEvents() {
    if (storedEvents.length !== 0) {
        var eventString = JSON.stringify(storedEvents);
        storedEvents = [];
        // send eventString to server
    }
    window.setTimeout(broadcastEvents, BROADCAST_TIMER);
}

There’s an obvious race condition in there and not even think of the missing memory barriers.

What to do? Really missing the Java memory model here..

  • 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-27T04:02:30+00:00Added an answer on May 27, 2026 at 4:02 am

    There isn’t any race condition.

    All JavaScript code in the browser is single-threaded.

    The setTimeout callback will run on the UI thread while it isn’t doing anything else.

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

Sidebar

Related Questions

Yes, it's the infamous viewstate again! Now I am aware that problems can ocurr
Yes, there is a similar question here . However, that question doesn't seem to
Yes, I know you could use regular objects as associative arrays in JavaScript, but
Yes, another NULL vs empty string question. I agree with the idea that NULL
Yes I want to read a simple a logfile into a TStringList and that
Yes, this is another Pivot question... I've read through nearly all the previous questions
Yes, this is rather subjective, but I am doing research on that matter and
Yes, I know about addons such as Firebug or the Web Developer Toolbar that
Yes, I know that my problem is not the unique, but I have analysed
Yes I know that that what I want (git cp a b) approximately equal

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.