[Javascript] atomic operations
Andrew Clover
and-babble at doxdesk.com
Wed May 3 09:00:30 CDT 2006
liorean wrote:
> So multiple events, timeouts etc. will all be scheduled for execution
> one after the other, and they will all be performed in their entirety
> before the next one will start executing.
This makes perfect sense and *should* be what happens. Except, it isn't
always.
From bitter experience I know of two particular cases where it does not:
- In Firefox 1.5 (at least; probably all Mozilla, possibly other
browsers), when you call a browser dialogue function such as
window.alert(). At this point other event handlers/timeouts can fire and
their code will execute in the middle of the execution of the alert()ing
script block.
- In IE with Java (at least Sun Java 1.4 on IE6, probably all IE+Sun
Java; does not affect MS JVM), when you call any method (or access any
property) on an applet from JavaScript, other event handlers/timeouts
can fire and their code will execute in the middle of the execution of
the applet-calling code. This is especially pernicious where multiple
threads of script are trying to silently call an applet, as totally
random intermittant faults can result.
So whilst normally you don't have to worry about threading/re-entrancy
in JS, there are times when it can be an issue, and the whole issue
doesn't seem to be documented anywhere. Would be interested to hear
anything more definitive on this issue because it's a pretty basic part
of JavaScript that's usually taken for granted.
--
And Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/
More information about the Javascript
mailing list