How to synchronize multiple threads?

In certain load tests you want to make sure a bunch of threads reach a particular state before they proceed with the rest of the work. You cannot make sure that all threads execute a point simultaneously since the CPU scheduling would determine this. However you can move these threads to Ready. A ready-thread is a thread can be scheduled for execution on a particular core – http://msdn.microsoft.com/en-us/library/dd627187%28VS.85%29.aspx

“The WaitForMultipleObjects function determines whether the wait criteria have been met. If the criteria have not been met, the calling thread enters the wait state until the conditions of the wait criteria have been met or the time-out interval elapses.”

Here is a small example of how to start multiple threads and then let them proceed after all of them have reached a particular point in execution.