It has been my observation that (per window) the JavaScript runs on a single
thread. This thread also handles all of the UI events. Therefore, the two
image event handlers you mention will execute atomically. On the other hand,
using a setTimeout("foo()", 0) allows the current (and possibly other) event
to complete before foo executes. This changes the order of execution and
most importantly the state in which foo executes.
Someone please correct me if I am wrong.
-J
-----Original Message-----
From: Dann [mailto:da...@to...]
Sent: Tuesday, January 30, 2001 7:45 AM
To: dyn...@li...
Subject: Re: [Dynapi-Dev] ns6 w/h and browser advocacy
Hi,
Has anybody ever done some testing or wondered about the safety nature of
concurrent execution of code in JS ? It struck me that this timeout gimmick
has
been discovered over and over again, to apparantly fix a recurring issue. It
was
already pointed out by Cameron, that if you could fix this kind of behaviour
by
using a Timeout, you probably stumbled on a browser bug... usually, in my
years
of fooling around with JS, a Timeout could even prevent a browser from
crashing
entirely.
What exactly happens if you would hook load event handlers to to two images,
who
would fire simultaneously and call the same function, to change some common
global variables ?
CU,
Dann
|