The first approach to waiting for data from an external source is called polling. An application periodically queries the input port of an external device to check if it has new data. It is easy to implement but has significant downsides.
First, it wastes processor resources. Most poll calls report that data is not available yet and we need keep waiting. Since these calls do not lead to some data processing, it is waste of computing resources. Moreover, the polling interval should be short enough that it responds to an external event quickly. Developers should look for a compromise between the efficient utilization of processor power and reaction time.
Secondly, it makes the logic of the program convoluted. If the program should poll for events, for example, every 5 milliseconds, none of its subroutines should take longer than 5 milliseconds. As a result, developers...