[whatwg] WebWorkers vs. Threads

Kristof Zelechovski giecrilj at stegny.2a.pl
Mon Aug 11 13:07:00 PDT 2008


Guarding concurrent access to global variables is not enough if those
variables hold references to objects because an object can end up in a
logically inconsistent state if two threads try modifying its properties
concurrently.  The objects would have to be lockable to avoid corrupting
global state.
Even if you limit yourself to scalar variables, there is nothing to prevent
a script to define a compound state as a set of scalar variables, each one
with its own name.  While it is not a good programming practice, old code
does it a lot because it is (or was) more efficient to say 'gTransCount'
than 'gTrans.count'.
Chris

-----Original Message-----
From: whatwg-bounces at lists.whatwg.org
[mailto:whatwg-bounces at lists.whatwg.org] On Behalf Of Shannon
Sent: Monday, August 11, 2008 2:54 AM
To: Jonas Sicking
Cc: WHAT working group
Subject: Re: [whatwg] WebWorkers vs. Threads


Maybe I misunderstand the concept of "shared nothing" but I think 
denying access to global objects is unwise. Maybe in a low-level 
language like C that's a bad thing but high-level languages can 
serialise simultaneous access to variables to prevent crashes and 
deadlocks. Performance can be improved by explicitly declaring private 
thread variables using var.





More information about the whatwg mailing list