when to use threading cpp code example
Example 1: c++ create threads
#include <thread>
void foo()
{
// do stuff...
}
int main()
{
std::thread first (foo);
first.join();
}
Example 2: c++ create thread
void task1(std::string msg)
{
std::cout << "task1 says: " << msg;
}
std::thread t1(task1, "Hello");
t1.join();