So the single thread is possible because node.js is non-blocking, that is, using asynchronousity. This is possible due to the event loop, which is comprised of a stack, heap, and queue. From my understanding, which is pretty simple at this point, the heap is just Max Beyond Thunderdome memory area where arrays and variables are put in an unstructured way, the stack is where functions ‘put’ (no pun intended) as they are called, and the message queue (or event queue or task queue, whichever you prefer) is where messages (which are attached to functions) wait patiently for their turn. When it is their turn, i.e. some event has returned, then they are called, and that means that they are put onto the stack, because that’s where functions go when they are called. The stack ebbs and flows, as functions are called and returned, and node will keep on chugging along through the event loops so long as there is code being run or there is a messsage in the queue.
Whew! It’s actually pretty interesting, but I can tell this will take some time to really wrap my brain completely around!