It's hard to understand the single thread of Javascript.
For example, writing a while (true) for C-system programming is not a very stressful thing. There doesn't seem to be any surprises in Nodejs, because there's a message mechanism to manipulate--it's just your illusion of nodejs, or that's just my illusion of nodejs. If the sub-process is written like this:
Process.on (' message ', function () {while (true);}); Process.on (' SIGINT ', function () { console.log (' Child Process killed by SIGINT Signal. '); Process.exit ();}); Process.on (' SIGTERM ', function () { console.log (' Child Process killed by SIGTERM Signal. '); Process.exit ();});
What happens when the main process sends a Kill? On my MAC, the child process gets out of control, the CPU runs full, and the fan goes crazy.
Because in Nodejs, a while (true) allows EventLoop to die directly.
For Javascript, the setinterval is applied. Remember before is someone reminds me, will use setinterval, climb out of the pit to understand deeply, is the will use.
So, in Javascript, you should disable while doing round robin or waiting.
--------------------------------
In Nodejs, the concept of "threading" is implemented in so many ways, Process.nexttick, SetTimeout, Setimmediate, SetInterval, and asynchronous programming. But they are not really "threads", such as do not sleep (), do not have accurate timing, in fact, is still a thread, the process is just such a thread. If there is a need to pinch time to schedule the work, or more heavy-duty time-consuming work, still have to open the sub-process is similar.
--------------------------------
There seems to be no such concept of "critical area" in Nodejs and the problems it brings. Because you don't allow inter-process sharing of resources at all. Public data can only be written in third-party services. Static configuration Fortunately, written in a module is finished. Dynamic configuration and dynamic information ... The simplest is ... Read and Write files ... It's not a problem if it doesn't happen frequently. Frequently, you have to be on heavy equipment, such as Redis ...
--------------------------------
With Javascript, it's time to get a sense of how this language should be thought, or language, and its running strategy in Turing. When I interview someone asking for a language, the person who really uses it, says it, not what it does, but what it has and can't. The experience is the one who knows it.
It's hard to understand the single thread of Javascript