If not, then calling it multi-threaded is misleading to a programmer who needs such things, and instead you'll need to find a more accurate word.
If not, then calling it multi-threaded is misleading to a programmer who needs such things, and instead you'll need to find a more accurate word.
process.env.UV_THREADPOOL_SIZE = 10;
function startOne() {
const start = Date.now()
require('crypto').pbkdf2(String(start), 'secretSalt', 100000, 512, 'sha512', (error, result) => {
console.log(`${result.length}b took ${Date.now() - start}ms`);
startOne();
});
}
for (let i = 0; i < 10; i++) startOne();
You can use htop or another tool of your choice to confirm this is the case.If you are talking more generally about anything we can run within Node.JS, is using Node.JS user-facing APIs and works without doing any modifications to Node.JS, the answer is yes. You can easily achieve that with node's native module support, and I would encourage you to do so over committing the folly of doing anything CPU intensive in JS.
That is if you manage to find any CPU intensive task that isn't already handled by node built-ins or some library out there.
Edit:
Now you may say: "Ahah! You can't use threads using [limited usage of node]. Also threads must be usable for arbitrary workloads in order to consider a thing multi-threaded. Node.js is single-threaded!"
I just can't argue with that. It's just a matter of opinions now about what makes a thing/environment single-threaded, and what makes it multi-threaded.
To me it's simple: [x] Thing uses multiple threads to perform work.