In most programming languages, I/O operations are performed synchronously. Synchronous execution will block the program flow until the blocking operation finishes its execution. For example, the following Python code is executed synchronously and blocks the execution:
file_content = open("my_file.txt") // takes 10 secondsfile_content_2 = open("my_other_files.txt") // takes 20 secondsprint file_contentprint file_content_2
The total execution time will be approximately 30 seconds. That is because of the I/O Blocking operation. If we represent the synchronous execution as a timeline:
Now if we execute the same operation in an asynchronous ...