title: Is JavaScript single threaded? If not, how do I get synchronized access to shared data?
body: <p>I have a web page with <code>DIV</code>s with a <code>mouseover</code> handler that is intended to show a pop-up information bubble. I don't want more than one info bubble to be visible at a time. But when the user moves the mouse rapidly over two items, I sometimes get two bubbles. This should not happen, because the code for showing a pop-up cancels the previous pop-up. </p>
  
  <p>If this were a multi-threaded system then the problem would be obvious: there are two threads trying to show a pop-up, and they both cancel existing pop-ups then pop up their own pop-ups. But I assumed JavaScript is always run single-threaded, which would prevent this. Am I wrong? Are event handlers running asynchronously, in which case I need synchronized access to shared data, or should I instead be looking for bugs in the library code for cancelling pop-ups?</p>
  
  <p>Edited to add:</p>
  
  <ul>
  <li>The library in question is <a href="http://code.google.com/p/simile-widgets/" rel="nofollow noreferrer">SIMILE Timeline</a> and its Ajax library;</li>
  <li>The event handler does call <code>SimileAjax.DOM.cancelEvent(domEvt)</code>, which I assume based on the name cancels the bubbling of events;</li>
  <li>Just to make thing s more complicated, what I am actually doing is starting a timeout that if not cancelled by a <code>moustout</code> shows the pop-up, this being intended to prevent pop-ups flickering annoyingly but annoyingly having the reverse effect.</li>
  </ul>
  
  <p>I'll have another poke at it and see if I can work out where I am going wrong. :-)</p>