1 回答

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超6個(gè)贊
nodejs是一種單線程模型,但是,使用nodejs的child_process模塊可以實(shí)現(xiàn)多進(jìn)程任務(wù)。利用child_process可以創(chuàng)建子進(jìn)程,實(shí)現(xiàn)子進(jìn)程和主進(jìn)程之間的通信。
nodejs v0.12.7版本child_process提供以下同步和異步的方式創(chuàng)建進(jìn)程:
異步創(chuàng)建:
child_process.spawn(command[, args][, options])
options.stdio
options.detached
options.customFds
child_process.exec(command[, options], callback)
child_process.execFile(file[, args][, options][callback])
child_process.fork(modulePath[, args][, options])
同步創(chuàng)建:
child_process.spawnSync(command[, args][, options])
child_process.execFileSync(command[, args][, options])
child_process.execSync(command[, options])
- 1 回答
- 0 關(guān)注
- 913 瀏覽
添加回答
舉報(bào)