have a doubt about Workers. lets consider this snipper:
// client code
var w = new Worker("myWor.js");
// in the worker
onmessage = function() {
// blablabla
}
is
w.terminate() // in client code
the same as
self.close() // in worker ciode
???
I made some tests and it does look like both the instructions terminate the worker which in turn stops answering to messages but I thought to double check with you guys.
w.terminate() and self.close() can be compared when powering down a computer.
w.terminate() is like pulling the plug, and self.close() is like performing a safe shutdown.
w.terminate() doesn’t give the worker any opportunity to complete its operations or to cleanup properly, so it’s better to use self.close() as much as you can.
by the way have u managed to have the onclose event to fire at all? it is in the spec and it should be fired when calling close() but it looks like its not working. Or maybe am doing something wrong
ok so to summarize: close() and terminate() do exactly the same thing. Only if u use close() it means u r IN the thread and can therefore do some operations before shutting down which u cant do from OUTSIDE (where u can instead use terminate).
but technically they do the same thing.
correct?
by the way I have an ex colleague from christchurch. howz it going downunder?
Landing an aircraft is very different from having jet fighters bomb it out of the sky. Sure, technically the aircraft ends up on the ground in both situations, but one (self.close()) is very much the preferred option over the other (worker.terminate())
We’re still shaken. It’s likely to take a whole generation for the place to return to mostly it was. Not in 5 years, some in 10, many parts in 15, most in 20.