Multithreading: Threads
This lesson illustrates the best practices used to implement multithreaded applications in C++.
We'll cover the following...
Threads
Threads are the basic building blocks for writing concurrent programs.
Use tasks instead of threads
Press + to interact
// asyncVersusThread.cpp#include <future>#include <thread>#include <iostream>int main(){std::cout << std::endl;int res;std::thread t([&]{ res = 2000 + 11; });t.join();std::cout << "res: " << res << std::endl;auto fut= std::async([]{ return 2000 + 11; });std::cout << "fut.get(): " << fut.get() << std::endl;std::cout << std::endl;}
Based on the program, there are a ...
Access this course and 1400+ top-rated courses and projects.