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