std::vector<std::thread> threads; //create threads for (int i=1; i<=10; ++i) threads.push_back(std::thread(increase_global,1000)); //wait for them to complete for (auto& th : threads) th.join();