Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
How to use wroker threads in nodejs to make the code excute faster?

I have a js file that contains multiple functions inside it, that can be exported to other js files and then I do some tasks. but the issue is there are some functions that take so much time like there is a function that renames thousands of files on a file system that totally blocks the electron UI for 30 seconds. here is how my file looks like:

const someModules = require("some-nodejs-modules");

function async first_CpuIntensive_Func(){
//some cpu intensive tasks
//some regexps
return someData;
}
function async second_CpuIntensive_Func(){
//some cpu intensive tasks
//some regexps
return someData;
}




module.exports = {first_CpuIntensive_Func,second_CpuIntensive_Func}

I am new to nodejs worker threads need help. Or is there any solution besides worker threads?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Your functions are not async in your example, update your knowledge async functions
  2. You may want to use async fs wrapper MZ\FS awailable in npm to make asyncronous file reads\writes
  3. If you really need worker threads (which is a pretty complicated topic) then you just read the docs concerning NodeJs cluster module
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!