Nothing fancy required; just use assignment. Inside your loop, write
myThreads[i] = std::thread(exec, i);
and it should work.
Nothing fancy required; just use assignment. Inside your loop, write
myThreads[i] = std::thread(exec, i);
and it should work.