You're using WaitForMultipleObjects incorrectly.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687025%28v=vs.85%29.aspx
The 2nd parameter should be a pointer to an array of HANDLEs. I'm not entirely familiar with the function, but it seems to me that if you want to wait for 16 threads to finish, you have to give WaitForMultipleObjects a pointer to an array containing all 16 HANDLEs for all the threads you want to wait for.
And for that matter... you are trying to wait for all 16 threads inside the loop..... so it will start waiting after only 1 thread has been created. That's probably not what you wanted.
Furthermore... I'm not entirely sure _beginthreadex returns a HANDLE, so your cast on line 64 might be bad. According to the msdn page it returns a uintptr_t which is probably
castable to a HANDLE but I don't know if it represents the same thing or not.
http://msdn.microsoft.com/en-us/library/kdzttdcb%28v=vs.71%29.aspx
Also... why are you passing
&myData
to CloseHandle? myData isn't a HANDLE, so what exactly are you trying to close?
Also according to the docs I'm reading on MSDN, _beginthreadex only takes 6 parameters, not 7... so I don't see how this would even be compiling.
And a stack size of 16 bytes? That's waaaaaay too small to do anything. Just use the default stack size.