create n threads cpp 1

create n threads cpp

std::thread* myThread = new std::thread[n];
for (int i = 0; i < n; i++)
{
	myThreads[i] = std::thread(exec, i);
}

Here is what the above code is Doing:
1. Create an array of threads
2. Create a thread for each element in the array
3. Execute the function exec() on each thread

Similar Posts