I am creating threads and each thread is writing something in a file, which a shared resource. I want all threads to finish the callback function, which is filewrite and then close.
For that, I am using WaitForMultipleObjects to wait for all threads to finish. But it never waits. This program creates all handles and immediately closes them. If I add Sleep(2500), then the threads seem to write in the file. Not sure what's going on?