[whatwg] WebWorkers vs. Threads

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

Received on Thursday, 14 August 2008 00:34:31 UTC