Simplest way to enable multi-threading in Nodejs. No configuration needed. Just plug and play.
npm install node-multithreadInstall with npm install --save node-multithread
v1.0.2 :
1) Breaking change for import syntax.
2) Added runOnce function for code that only needs to run once.
runOnce(() => console.log("this will print only once"));
multithread(() => {
// Your code goes here
//...
eg :
const express = require('express');
const app = express();
const port = 3000;
console.log("This will print as many times as threads");
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(Example app listening on port ${port}!))
}, 4); // Optional parameter after callback to limit threads.