O'Reilly logo

Professional C++, Second Edition by Scott J. Kleper, Nicholas A. Solter, Marc Gregoire

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required