|
|
|
|
|
by jeresig
6170 days ago
|
|
That can't work because the individual methods may contain a closure to a non-threadable object (like the DOM). The reason why all of the logic is forced into in an external script is to prevent contention from occurring - your proposed solution definitely would not allow for that. On the other hand, allowing for an easy way to call global functions of the child worker would be really nice. var worker = new Worker("worker.js");
worker.start();
Child Worker: start = function(){
// Gets called by the parent
};
That would be sexy and surely simplify a lot of logic surrounding message passing. |
|
Threads we can fire and forget. Threads we can start "inside" our script and let them work while we do other stuff.
Asynchronous like xmlhttprequest, just a way to replace the "settimeout" hack.