由于JavaScript是单线程的,HTML5中的Web工作者如何进行多线程处理? [英] Since JavaScript is single-threaded, how are web workers in HTML5 doing multi-threading?
问题描述
我一直在阅读HTML5中的网络工作者,但我知道JavaScript是单线程的。
我的问题是:
web工作人员如何进行多线程工作?或者如果它不是真正的多线程,他们如何模拟它?在这里看起来并不清楚。
正如几位评论已经指出的那样,工作者确实是多线程的。 / b>
有些问题可能有助于澄清您的想法:
I've been reading about web workers in HTML5, but I know JavaScript is single-threaded.
My question is:
How are web workers doing multi-threaded work then? or how are they simulating it if it's not truely multi-threaded? Doesn't seem clear to me here.
As several comments have already pointed out, Workers really are multi-threaded.
Some points which may help clarify your thinking:
- JavaScript is a language, it doesn't define a threading model, it's not necessarily single threaded
- Most browsers have historically been single threaded (though that is changing rapidly: IE, Chrome, Firefox), and most JavaScript implementations occur in browsers
- Web Workers are not part of JavaScript, they are a browser feature which can be accessed through JavaScript
这篇关于由于JavaScript是单线程的,HTML5中的Web工作者如何进行多线程处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!