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

232
Vistas
Nested Threads For Nested Functions?

I currently using async/await method and that's helpful with https requests but doesn't help with synchronous code.

What can I do to improve performance in that case?

Can I use something like nested worker threads?

I can use worker threads in the last functions but I want to be able to use them in nested mode!

Is it possible to do something like that in javascript/node.js or I have to switch language/platform!?

Code example:

(async(){
    /*Some code*/
    let Items=[]; //Long array
    for(let Item in Items){
        (async(){
            /*Some code*/
            let Items=[]; //Long array
            for(let Item in Items){
                (async(){
                    //And so on ...
                })();
            }
            /*Wait until all functions done*/
            /*Some code*/
        })();
    }
    /*Wait until all functions done*/
    /*Some code*/
})();

Best answer until now: Using shared resources between threads, Because threads can't run in nested mode (making a tree/within each other)!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Yes, code can use something like Node.js Worker threads to allow parallelism for CPU-bound work.

Workers (threads) are useful for performing CPU-intensive JavaScript operations. They do not help much with I/O-intensive work. The Node.js built-in asynchronous I/O operations are more efficient than Workers can be.

The async concurrency model is still used and each execution context is single-threaded.

The worker threads are themselves running in separate execution contexts and, conceptually in context of await (eg. of promise wrappers around the events), using worker threads is little different than using XHR to dispatch processing to remote compute servers.

Unlike more direct multithreaded support in other languages, this also comes with the restriction that objects are not implicitly shared between the node app and any worker threads, as they are not shared in remote XHR work. Code will need to be written to appropriately divide data and join results or otherwise marshal through a shared resource (eg. filesystem or SharedArrayBuffer).

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