I am having a hard time understanding how the pool in NodeJS works. How does async function work all at a time?
Does the event loop allocate threads from the thread pool for every async Function? If yes, please look at the code below
const saySomething = async(arg)=>{
try{
for(i=0;i<=10000;i++){
console.log(arg)
}
}
catch{
}
}
saySomething("Muthu")
.then(()=>{})
.catch(()=>{})
saySomething("Raj")
.then(()=>{})
.catch(()=>{})
saySomething("Candy")
.then(()=>{})
.catch(()=>{})
saySomething("Python")
.then(()=>{})
.catch(()=>{})
While running, I am seeing like it is being executed only by one thread; even though 4 threads are running concurrently by time-sharing and context-switching in OS. If not, is my assumption wrong? Please, help me out...