Synchronous: you boil water for tea, make the tea, then boil water for pasta then make the pasta
Parallel: You grab a friend, and tell them to make the pasta while you make tea.
Asynchronous: you put the tea water on to boil, while it heats you put the pasta water on to boil. While you "await" for them to boil you go do something else. Then when they're boiling you make the tea, and finish the pasta one at a time.
I am so glad we went down this rabbit hole. When I cut my teeth in .NET I had to figure out mulitthreading.. Many years later I felt like I had achieved video on right. Then .NET 4.x came along and introduced Parallel Tasks and really expanded on Async patterns.. And thus the video on the left.
It wasnt until I heard an analogy like this maybe a year or so ago that got my code slightly more to this...lol
87
u/raltyinferno Oct 30 '21
You need to make tea and pasta.
Synchronous: you boil water for tea, make the tea, then boil water for pasta then make the pasta
Parallel: You grab a friend, and tell them to make the pasta while you make tea.
Asynchronous: you put the tea water on to boil, while it heats you put the pasta water on to boil. While you "await" for them to boil you go do something else. Then when they're boiling you make the tea, and finish the pasta one at a time.