📜  nodejs 是否每个工作线程都需要一个新内核 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:27.703000             🧑  作者: Mango

代码示例1
A worker thread in node.js is an actual OS thread running in 
  a different instance of V8. As such, it's totally up to 
the operating system to decide how to allocate it among 
available CPU cores. If there are cores with available time, 
  then it will not generally be run on the same core as the
  main nodejs thread when that thread is busy because the OS
  will allocate busy threads across the various cores.

But, again this is entirely up to the OS and is not something 
that nodejs controls and the exact strategy for which cores 
are used will vary by OS. But, in all modern operating systems, 
  the design goal is that available cores are used for threads 
  that are currently executing. Now, if there are more threads 
  active at once than there are cores, the threads will be 
  time-sliced and all the cores will be active.