45
edits
Changes
→What are C++ 11 Threads
Before C++ 11 in order to implement multi-threading, external libraries or language extensions such as OpenMp was required. Not only the standard library now include support for multi-threading,
it also offered synchronization and thread safety.
The C++ 11 thread support library includes these 4 files to enable multi-threading
* <contition_variable> - a synchronization primitive that can be used to block a thread, or multiple threads at the same time, until another thread both modifies a shared variable (the condition), and notifies the condition_variable.
* <future> - Describes components that a C++ program can use to retrieve in one thread the result (value or exception) from a function that has run in the same thread or another thread.
Two options are available for multi-threading. Synchronous threading via std::thread and Asynchronous threading via std::async and std::future.
===Creating and executing Threads===