[whatwg] WebWorkers vs. Threads

Aaron Boodman aa at google.com
Thu Aug 14 00:34:31 PDT 2008


On Thu, Aug 14, 2008 at 12:23 AM, Kristof Zelechovski
<giecrilj at stegny.2a.pl> wrote:
> Sorry, I do not get it.  Where does the value of (la) make it into
> (e.message)?

Sorry, I forgot a line:

> // main.js
> var la = 0; // what is with this variable name?
> var worker = createWorker("worker.js");
> worker.port.addEventListener("message", function(e) {
>  la = parseInt(e.message);
>  alert(la);
> }, false);

worker.port.sendMessage(la);

> // worker.js
> workerGlobalScope.port.addEventListener("message", function(e) {
>  workerGlobalScope.port.sendMessage(
> someLongRunningFunction(parseInt(e.message)));
> }, false);

Code not tested, so there still might be mistakes. But I hope the
point gets across.

- a



More information about the whatwg mailing list