Multithreading: Threads
Explore the fundamental concepts of threads in modern C++ concurrency. Understand why using tasks is often preferable to raw threads, learn how to safely communicate between threads, avoid race conditions, and implement joinable threads using wrappers to maintain thread safety.
We'll cover the following...
We'll cover the following...
Threads
Threads are the basic building blocks for writing concurrent programs.
Use tasks instead of threads
Based on the program, there are a lot of reasons for preferring tasks over threads. These are the main reasons:
- you can use a safe communication channel for returning the result of the communication. If you use a shared