对于我正在开发的应用程序,我需要并行启动共享库的实例。
由于我希望对并行实例的数量进行细粒度控制(-license of library限制并行数量到固定数量的线程),我想知道是否有一种简单的方法来创建和维护本机模块中的自己的线程池?
谢谢!
答案 0 :(得分:0)
Basically we must set the UV_THREADPOOL_SIZE environment variable before the thread pool is created.
This can be done in three ways:
Putting this line in your .bashrc file will affect all the opened node processes under that user
export UV_THREADPOOL_SIZE=10
Set it before the process is open
UV_THREADPOOL_SIZE=10 node myscript.js
Set it inside the javascript, in the first line:
process.env.UV_THREADPOOL_SIZE = 10;