Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda