我无法解决以下问题: 我有10个线程不需要彼此交互,因此都可以同时运行。 我在循环中创建它们。 但是,我需要等到所有线程都完成后,才能继续执行for循环之后的代码。 这里是伪代码的问题:SDL和C++:等待多线程完成
//start threads
for (until 10) {
SDL_Thread* thread = SDL_CreateThread();
}
//the rest of the code starts here, all threads need to be done first
什么是完成这件事的最佳方式?
我需要保持与该问题无关的平台,这就是为什么我只尝试使用SDL函数。
如果还有另一个独立于C++的平台解决方案,那我也很好。
如果你可以使用'C++ 11',你可以在'C++ 11'中查看线程支持:http://en.cppreference.com/w/cpp/thread – olevegard 2014-08-30 07:53:13