Concurrency versus thread safety
Concurrency is the concept of multiple tasks executing in overlapping periods. These tasks can either run at the same time on different processing units or might interleave on a single processing unit. The main goal of concurrency is to increase the system’s responsiveness and throughput. Concurrency is beneficial in various scenarios, such as when designing servers that handle multiple simultaneous client requests or in user interfaces that must remain responsive while processing tasks in the background.
In C++, concurrency can manifest in multiple forms: multi-threading, where separate threads of execution run (potentially) in parallel, or asynchronous programming, in which specific tasks are offloaded to be executed later.
In C++, it’s crucial to understand that concurrency and thread safety are related but distinct concepts. Concurrency refers to the program’s ability to execute multiple sequences of operations simultaneously...