Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Asynchronous programming is a programming paradigm where execution of a code does not happen in a continuous, linear fashion. When writing synchronous code, each line of code gets executed one after the other, and the next line only starts running after the current line completes.

In contrast, in asynchronous programming, multiple tasks can be executed concurrently, without waiting for the previous task to complete. In this way, a program can still continue to run and be responsive, even if one task is taking longer than expected.

One common way asynchronous programming is implemented is through the use of callbacks or promises. Here, instead of the program blocking while a resource is being fetched, for example, the program can continue executing other code and when the resource is fetched, the callback function is invoked.

Asynchronous programming is especially useful when dealing with input/output (I/O) operations, such as network requests or file reading, where the completion time of the operation is unpredictable. By using asynchronous programming, a program can be more efficient and responsive.