Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda