Mark Space wrote:
sources (hello XMLHttpRequest) and will spawn additional threads of
can be a huge hassle. There's an algorithm available to synchronize
threads using only shared memory. Read on:
I believe that, in the case of XMLHttpRequest, in Mozilla, everything is
proxied back to the display thread. The definition of XMLHttpRequest
also appears to not be thread-safe, which means that using the object
from multiple threads is more or less A Bad Thing?.
Although the SpiderMonkey engine is very much capable of doing
multithreaded execution, the DOM itself is not threadsafe and has to be
modified from a single thread, so must browser JS ends up running in one
web browsers are conceptually single threaded with respect to the web page."
Yes, I am aware of DOM workers, but these do not allow concurrent access
to the DOM:
"The DOM APIs (Node objects, Document objects, etc) are not available
to workers in this version of this specification."
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth