funthreads
Version:
A lightweight tool built on top of Node.js worker_threads, enabling multithreading.
19 lines (15 loc) • 365 B
JavaScript
const { executeInThread } = require('funthreads');
// this will be executed in a dedicated thread
const task = (a, b, c) => {
console.log('a', a, typeof a);
console.log('b', b, typeof b);
console.log('c', c, typeof c);
};
async function start() {
try {
await executeInThread(task, 1, {}, true);
} catch (err) {
console.log(err);
}
}
start();