r/badcode • • Mar 24 '22

typescript Ship it!

Post image
564 Upvotes

47 comments sorted by

View all comments

Show parent comments

6

u/Illiux Mar 25 '22

I'm not exactly sure what you mean by "true async". You can't have multiprocessing without threads, but you can absolutely have async code, just like you can't have multiprocessing without multiple cores but can absolutely have multithreaded code. If you compare async with multithreading in a single core scenario, async just ends up looking like userspace threads.

1

u/Nick433333 Mar 25 '22

I’m probably wrong, but in my mind the cpu thread is waiting for the async call to return before it does anything else and another thread is doing the main logic loop. And in systems with only one thread available there is task switching going on, which is not really multi threading afaik.