process模型7如何解釋結(jié)果 Node.js中child_process實(shí)現(xiàn)多進(jìn)程?
Node.js中child_process實(shí)現(xiàn)多進(jìn)程?Nodejs是一個(gè)單線程模型,但是,使用Nodejs的子進(jìn)程模塊可以實(shí)現(xiàn)多進(jìn)程任務(wù)。使用子進(jìn)程可以創(chuàng)建子進(jìn)程,實(shí)現(xiàn)子進(jìn)程與主進(jìn)程之間的通信。nod
Node.js中child_process實(shí)現(xiàn)多進(jìn)程?
Nodejs是一個(gè)單線程模型,但是,使用Nodejs的子進(jìn)程模塊可以實(shí)現(xiàn)多進(jìn)程任務(wù)。使用子進(jìn)程可以創(chuàng)建子進(jìn)程,實(shí)現(xiàn)子進(jìn)程與主進(jìn)程之間的通信。nodejsv0.12.7 childProcess提供以下同步和異步方法來(lái)創(chuàng)建進(jìn)程:異步創(chuàng)建:child進(jìn)程.spawn(命令[,參數(shù)][,選項(xiàng)])選項(xiàng).stdio選項(xiàng).分離選項(xiàng).customFds兒童進(jìn)程.exec(命令[,選項(xiàng)],回調(diào))子項(xiàng)uprocess.execFile文件(文件[args][,options][callback])子項(xiàng)u過(guò)程.fork(modulepath[,args][,options])同步創(chuàng)建:childu進(jìn)程.spawnSync(命令[,參數(shù)][,選項(xiàng)])子項(xiàng)u進(jìn)程.execFileSync(命令[,參數(shù)][,選項(xiàng)])子項(xiàng)u進(jìn)程.execSync(命令[,選項(xiàng)])