cpp how many threads to open code example
Example 1: c++ create threads
#include <thread>
void foo()
{
// do stuff...
}
int main()
{
std::thread first (foo);
first.join();
}
Example 2: multiple threads cpp
#include <iostream>
#include <threads>
#include <vecotr>
std::vector<std::thread*> threads;
for(int i = 0; i < x; i++)
{
threads.push_back(new std::thread(func));
}