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
Amazing answer !
Love your answer !