Q:

WaitForMultipleObjects alternative with std::thread?

My problem is that I have multiple threads, they are stored in some container, and I need to know when a thread at a certain position finished.
On windows I would do something like:
HANDLE handles[3];
//handles were initialized
DWORD finishingThread = WaitForMultipleObjects(3, handles, false, INFINITE)

Is there any way to achieve the same effect with std::thread?

A:

To the very best of my knowledge, there is nothing in the standard library that supports a wait of that nature. The standard library is built on top of the underlying operating system threading support. By necessity the standard library can only offer lowest common denominator functionality. Which means that it is not able to wrap some of the richer functionality offered by the Win32 threading library.

A:

Just use a std::condition_variable and have your threads fire notify_all() or notify_one() right before they finish.
Then do cv.wait() where you want your WaitForMultipleObjects() call.

