Chapter 22

imageMultithreaded Programming with C++

WHAT’S IN THIS CHAPTER?

  • What multithreaded programming is and how to write multithreaded code
  • What deadlocks and race conditions are, and how to use mutual exclusion to prevent them
  • How to use atomic types and atomic operations
  • What thread pools are

Multithreaded programming is important on computer systems with multiple processors. It allows you to write a program to utilize all those processors in parallel. Systems with multiple processors already exist for a long time; however, they were rarely used in consumer systems. Today, all major CPU vendors are selling multicore processors. A multicore processor physically looks like a single processor, but inside it contains several parallel CPU processors, also called cores. Nowadays, multicore processors are being used for everything from servers to consumer computers. Even the latest smartphones have multicore processors. Because of this proliferation of multicore processors, writing multithreaded applications is becoming more and more important. A Professional C++ programmer needs to know how to write correct multithreaded code to take full advantage of all the available processors and cores. Writing multithreaded applications used to rely on platform- and operating system-specific APIs. This makes it difficult to write platform independent multithreaded code. C++11 solves this problem ...

Get Professional C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.