Used WaitForSingleObject instead of GetExitCodeThread to wait for threads.
Used WaitForSingleObject instead of GetExitCodeThread to wait for threads.

This uses the suggestion from "ujos" to use WaitForSingleObject, which
is (according to MSDN) the more appropriate way to obtain notification about
a thread's exit status.

One possible problem I've noticed is that it appears that the way a C++ process
terminates under Windows might have changed recently. It seems that before,
the global object destructors (i.e. VLD's) got called before the ExitProcess
Win32 API was called (and terminated all threads). Now I'm seeing different
behavior: the destructors are called *after* ExitProcess is called. So it may
very well be that this code never gets used anymore as it may now be guaranteed
that all threads exit before VLD's destructor is called. Which can mean that
threads get stomped ungracefully by the Windows kernel, and I'm not sure if
there is a way for VLD to detect (and warn about) this.

smanders/vld,dmoulding/vld,KindDragon/vld,ioannis-e/vld,akaStiX/vld,zcnet4/vld,KindDragon/vld,erdincay/vld,zcnet4/vld,ioannis-e/vld,erdincay/vld,smanders/vld,akaStiX/vld,slideclick/vld,slideclick/vld,dmoulding/vld