Easy to understand definition of "asynchronous event"? [closed] Easy to understand definition of "asynchronous event"? [closed] javascript javascript

Easy to understand definition of "asynchronous event"? [closed]


Non programming example:

SynchronousYou want a pizza for dinner and you are out of the frozen kind. So you have to stop playing WOW which upsets your guild. You go to the kitchen, make the dough, cover it with sauce, add the cheese, and smother it your favorite bacon topping. You just spent 20 minutes of your time making the pizza with another 10 minutes in the oven. The timer beeps and you pull the hot pie out. You can sit back down in front of your computer, eat the pizza, and continue with your raid.

AsynchronousYou want a pizza for dinner while playing WOW. You open up a browser window on your 5th monitor. You load up the Pizza website and order your extra cheesy bacon pizza with a side of bacon grease garlic sauce. You go back to your raid and after 20 minutes the door bell rings. You get the pizza. You sit back down in front of your computer, eat the pizza, and continue with your raid.

So what is the difference? One way you waste 20-30 minutes of precious WOW time, the other way you waste $20 plus tip.


Your page is delivered from the server to a client browser, somewhere out there in the Internet. The browser has drawn the page on a screen, and somebody — or some thing — is looking at it. It's a waiting game. Eyes shift back and forth, taking in this or that detail in quick jumps, darting to the side now and then, away from the screen, to investigate distractions in the environment. The clock ticks. The page glows softly, passively, as the user hovers inactive, hand loosely draped over a mouse, neck bent down and eyes more and more intent on something inviting that your page has to offer.

Suddenly, without any warning at all, the cursor begins to move as the hand on the mouse stiffens slightly and begins nudging the little plastic bump over the rough surface of the table. As the mouse moves, its surrogate on the screen moves in close imitation, grazing past interesting images and witty remarks in the content of your page. Eventually a decision is made, the movement pauses, a muscle or two contract slightly, and the mouse button is depressed by an insistent finger. The microswitch in the mouse triggers an electronic impulse, and suddenly the browser is made aware of what's happened: a mouse click.

In all that, everything about what the user has done while gazing at the page has happened in a way totally unpredictable to the browser, to any client code in your web page, to anything resident on your servers. There was no knowable "wait time" between human actions. The actions, therefore, as transmitted by the equipment hooked to the user's computer, happened when they happened and not according to a predictable clock — that is, they happened asynchronously.


Think of the end of an interview, and they guy says, "Don't call us, we'll call you". That is the essence of an asynchronous event.

Normally you define functions and you call functions explicitly. Your program has a structure where it starts from line 1, then line 2, and except for some conditional code and iterations, calling functions, etc., there is a simple, liner, synchronous structure.

But in some cases you have actions that are triggered by events outside of the direct control of the program, things that come from outside the program, like a user interface events (user clicks the mouse) or a network event (someone tries to connect to your server). Your code does not generate these events directly. They are generated outside of your program, often by the OS based on their monitoring of user interface devices and other systems. These are called asynchronous events.

Just remember, "Don't call us, we'll call you"