Women in Technology

Hear us Roar



Article:
  Implementing Mutual Exclusion for AJAX
Subject:   Browser Javascript implementations are single threaded...
Date:   2006-04-05 16:04:47
From:   BobLee
So you've solved a problem that doesn't exist. Didn't we already address this in the comments on Ajaxian? http://ajaxian.com/archives/ajax-from-scratch-implementing-mutual-exclusion-in-javascript#comments
Full Threads Newest First

Showing messages 1 through 4 of 4.

  • Browser Javascript implementations are single threaded...
    2006-04-06 07:19:33  jdodds [View]

    "Browser JavaScript implementations are single threaded" is, unfortunately, not actually a true statement.

    Microsoft Internet Explorer (surprise, surprise) breaks the single threaded JavaScript model. Many of the host objects in IE are implemented as COM objects and Microsoft did not architect the integration in a way that protects the integrity of the JavaScript language. Hence you have issues like closures that capture DOM objects leaking memory. It also means that callbacks into JavaScript from COM objects are usually on a different thread, the thread that's running inside the COM object.

    I haven't had to deal with these kind of issues for a while but my possibly faulty recollection is that setTimeout() will perform a thread context switch. So the onreadystatechange handler should not directly operate on a request result but instead should package the result in a closure and then use setTimeout to push processing back onto the primary JavaScript thread.
    • Browser Javascript implementations are single threaded...
      2006-04-06 12:34:33  BobLee [View]

      Can you provide some example code that demonstrates the problem you're trying to solve?
      • Browser Javascript implementations are single threaded...
        2006-04-06 13:20:37  jdodds [View]

        Are you confusing me with Bruce Wallace?

        BTW I don't like his 'solution'.
        • Browser Javascript implementations are single threaded...
          2006-04-06 13:26:48  BobLee [View]

          Yup. Sorry. :(