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

340
Vistas
nodejs main thread and event loops, what is the difference between?

When http request hit into the Nodejs application the connect first received by Nodejs main thread (which is js main thread) and passed to event loop, if my understand is correct

The event loop is what allows Nodejs to perform non-blocking I/O operations, JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.

The above statement is from Nodejs official documentation, so my question where does the main thread lives?

out side the event loop or inside the event loop

is both different? Can someone give good pictures how Nodejs work internally, with graphical representation?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Main thread is the execution thread. As asked, it stays outside the event loop and will check for any events pertaining to the event loop.

If the even added to the event loop is synchronous and only needs some CPU operations, the main thread will take control directly and will execute the need.

If an asynchronous event is added to the event loop that is delegated to the worker threads available. Worker threads will perform the async operation(db/API/fs calls). Once the async part of the event is completed the event is again added to the event loop for the execution of the remaining synchronous part.

The worker threads are built over libUV and will spawn according to the main thread requirement. This reason makes Node.js more efficient while handling async calls and less preferred for CPU extensive operations.

Follow this for a more detailed explanation:
What function gets put into EventLoop in NodeJs and JS

about 4 years ago · Santiago Gelvez 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