node.js - 问一个小白的问题,nodejs是单线程的,可是为什么支持开启子进程?
PHPz
PHPz 2017-04-17 11:08:47
0
1
471

这个问题可能显得很小白,可是我还是不太懂,网上说到nodejs大多是单线程,异步回调,IO非阻塞云云,感觉说的很有道理的样子,也能看进去一点,可是还是很迷茫。从学校学到知识线程是基于进程的。说nodejs是单线程,可是他有child_process支持开启子进程,这不就是多进程吗?多进程不就是意味着多线程?...

小白一个,求解释啊

PHPz
PHPz

学习是最好的投资!

reply all(1)
大家讲道理
  1. Single-threaded or multi-threaded generally refers to whether there is only one thread or multiple threads in a single process;
  2. The nodejs process itself does not have only one thread. My node v0.10.26 only has two threads when the interpreter is turned on;
  3. We say nodejs is single-threaded from the perspective of usage. Usually nodejs programs are written as if there is only one thread running (regardless of how many threads are actually working at the bottom);
  4. Nodejs programs are usually single-process, and the "multi-process" mode is rarely used, that is, multiple processes are started to work together. This does not mean that nodejs does not have the ability to start multiple processes.
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template