Does javascript refer to single process or multithreading?
This article will explain in detail whether javascript refers to single-process or multi-thread. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Javascript is a single process. As a browser scripting language, the main purpose of JavaScript is to interact with users and manipulate DOM, which determines that it can only be single-threaded, otherwise it will bring a lot of complex synchronization problems.
JavaScript is single-threaded, which is one of its major features. In other words, JavaScript can only do one thing at a time.
As a browser scripting language, the main purpose of JavaScript is to interact with users and manipulate DOM, which determines that it can only be single-threaded, otherwise it will bring complex synchronization problems. For example, suppose JavaScript has two threads at the same time, one thread adds content to a DOM node and the other thread deletes the node, which thread should the browser follow?
In order to take advantage of the computing power of multicore CPU, HTML5 proposes the Web Worker standard, which allows JavaScript scripts to create multiple threads, but child threads are completely controlled by the main thread and cannot operate DOM. Therefore, this new standard does not change the nature of JavaScript single-threading.
This is the end of the article on "javascript refers to single-process or multithreading". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.