Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does async necessary involves multithreading or parallelism?

Tags:

asynchronous

Or can we have asynchronous code that executes in the same thread.

like image 823
Adrian Zanescu Avatar asked Nov 22 '25 03:11

Adrian Zanescu


1 Answers

Actually, yes, you can have async code that executes in the same thread. Most basic IO these days is actually asynchronous; reads and writes are requested and processed outside the CPU, when they are complete a flag is set and then the program can address the values. The program does this by occasionally checking the value of the flag during it's normal processing and responding when the value indicates availability. The operating system will typically coordinate this for higher-level programs.

That's a really dumbed down version of the truth, but it's correct enough for this discussion. For more reading, I suggest you start here:

http://en.wikipedia.org/wiki/Asynchronous_I/O

like image 183
Randolpho Avatar answered Nov 25 '25 00:11

Randolpho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!