chapter one

1 Asynchronous programming and multithreading

 

This chapter covers

  • Introduction to multithreading
  • Introduction to asynchronous programming
  • Blending asynchronous programming and multithreading

As software developers, we often strive to make our applications faster, more responsive, and more efficient. One way to achieve this is by enabling the computer to perform multiple tasks simultaneously, maximizing the use of existing CPU cores. Two common techniques for this are multithreading and asynchronous programming.

Multithreading allows a computer to appear as if it is executing several tasks at once, even when the number of tasks exceeds the number of CPU cores. In contrast, asynchronous programming focuses on optimizing CPU usage during operations that would typically cause it to wait, ensuring the CPU remains active and productive.

Enabling a computer to perform multiple tasks simultaneously is incredibly useful. It helps keep native applications responsive while they work and is essential for building high-performance servers that can effectively interact with many clients at the same time.

Both techniques are effective for creating responsive client applications or servers that handle a few clients. But when combined, they can greatly boost performance, allowing servers to handle thousands of clients at the same time.

1.1 What is multithreading

1.2 Introducing multi-core CPUs

1.3 What is asynchronous programming?

1.4 Multithreading and asynchronous programming together

1.5 Software efficiency and cloud computing

1.6 Summary