How to design parallel applications

In order to prevent problematic situations, we need to first identify the possible scenarios. We can divide problems related to concurrency into two major categories:

  • Correctness problems: These can cause a program to produce incorrect results
  • Liveness problems: These can cause a program to stop producing results completely

Correctness problems are very hard to discover because of the nature of the concurrency itself. Since each thread takes a different execution path, these situations can occur at any point of time without the programmer realizing that the program's output is incorrect, and something went wrong. In the worst case, we can run such a program many times with the correct results before a scenario ...

Get C++ Multithreading Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.