在html5中,多线程worker和异步ajax有什么区别?
高洛峰
高洛峰 2017-04-17 13:29:51
0
2
426

在html5中,多线程worker和异步ajax有什么区别?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
洪涛

Multi-threading belongs to the category of concurrency, while asynchronous is the category of data request methods, as opposed to synchronization.

伊谢尔伦

I agree with the explanation above. The difference between them is huge. In terms of specific usage scenarios, CPU-consuming tasks can be moved to workers for processing. Ajax is mainly time-consuming for IO. In order to ensure that the code is not blocked, it is processed asynchronously and notified when the data arrives. program. This is a workaround in HTML5, because ajax was implemented relatively early, and worker is a relatively new concept. It can be said that the function of worker covers ajax, but such problems naturally arise due to the continuous development of HTML.
In other languages, time-consuming tasks are generally placed in other threads to avoid blocking the main thread. Regardless of whether it costs CPU or IO.
In short, it’s all HTML’s fault. You can also handle network requests in workers, but unfortunately, there are not many browsers that support workers.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!