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.
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.