views:

35

answers:

1

Does process have at least one thread running?

If so, then the Node.js will by default have 1 main thread and 1 event loop thread running?

+1  A: 

No, node.js runs only with one thread. There is no "main thread" and "event loop thread". First run the initialzation code then the event loop is entered. The event loop runs the event and timeout handlers. Exactly as in the browser: first run the initialization code in the <script> tags, then the handlers.

Except the workers, but also here it is the same as in the browser (HTML5 workers). A worker thread or process is started separately to offload long-running calculations and a handler is run when the worker finished its task.

nalply