Is there a better to start a new thread, other than using setTimeout?
Answered
Virginia's Warbler posted this in #help-forum
Virginia's WarblerOP
I inherited this project, saw setTimeout used in some strange ways, I asked prev dev, he said it was to start a new thread so it wont block.
Is there a better way?
Is there a better way?
7 Replies
@Virginia's Warbler I inherited this project, saw setTimeout used in some strange ways, I asked prev dev, he said it was to start a new thread so it wont block.
Is there a better way?
nodejs itself runs javascript code and that is single threaded. However it can feel like it's multi threaded especially when it comes to async stuff. To know why and how this is still possible, you want to watch this video, that explains it very well: https://www.youtube.com/watch?v=eiC58R16hb8
That will also answer your question why just creating a new setTimeout function would work and what alternatives you can use
That will also answer your question why just creating a new setTimeout function would work and what alternatives you can use
And even then it'd not be running truly concurrently. Only when it's an actual promise.
@Asian black bear And even then it'd not be running truly concurrently. Only when it's an actual promise.
put it inside it's own promise 

Virginia's WarblerOP
Thank you, thank you
@Virginia's Warbler Thank you, thank you
Please mark solution
Answer
Dwarf Hotot
In Nextjs you can use worker
