We discussed an example of asynchronous code execution when speaking about GUI applications. GUI components react to user actions by firing corresponding events, which are pushed in the event queue. This queue are then processed one by one by invoking attached handler functions. The described process happens in a loop; that's why we usually refer to the concept as the event loop.
Asynchronous systems are really useful in I/O operations because any input or output operation blocks the execution at the point of I/O call. For example, the following pseudo-code reads a file from a directory and then prints a welcome message to the screen:
auto f = read_file("filename");
cout << "Welcome to the app!";
process_file_contents(f);
Attached to the synchronous execution pattern, we know that the message Welcome to the app! will be printed...