I'm new to nodejs, and I became curious about how nodejs handles asynchronous tasks in nodejs.
After reading documents from nodejs docs, I found that nodejs chose event loop / non-blocking operation model.
The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.
What I understood is that nodejs event loop offloads non-blocking operations to the system kernel (and libuv
thread pool I think?) to perform tasks asynchronously.
So my question is, what is the "core" difference between this model and multi-threaded operations model? It just looks like multi-threaded operations using system kernel handled by main thread. Is it just the benefit of not wasting resources doing context-switching or something? Is it ok to understand like "yeah, nodejs is single-threaded but it's almost the same with multi-threaded system"?
I read some documents but I couldn't figure out the answer for my question.