Yesterday, I was working on a function in a test runner that executes synchronously. My task was to send a message to Slack. It sounds easy enough, I'm sure I could do it myself with a
request POST. However, NPM has packages available. I'll just pull one in.
I tried package after package. None of them worked. They never executed the actual POST. After some troubleshooting, it turns out they're all running in asynchronous mode. This promted me to think, "Do I even know what synchronous and asynchronous mean?" I thought I understood and my original function should have worked.
When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes.
Stack Overflow - Adam Robinson
BUT WHY?!?!?! It seems so counter intuitive. Synchronous should be code executing as the same time and asynchronous should be code executing one line at a time. Not suprisingly, other people were just as confused as I was.
Oddly enough "Synchronously" means "using the same clock" so when two instructions are synchronous they use the same clock and must happen one after the other. "Asynchronous" means "not using the same clock" so the instructions are not concerned with being in step with each other. That's why it looks backwards, the term is not referring to the instructions relationship to each other. It's referring to each instructions relationship to the clock. Hope that helps
Stack Overflow - Tom Padilla