Hi,
I'm trying to create a basic multi-threading application in C++. The problem is CreateThread() is too slow. Worse still, it doesn't appear to halt my program while the new thread is created, the code after CreateThread() gets executed before the thread is ready. I use Beep() just for debugging purposes. My code is below:
Code:
#include <windows.h>
#include <tlhelp32.h>
DWORD WINAPI runThread(LPVOID args);
bool isThreadReady = false;
int main()
{
DWORD dwGenericThread;
HANDLE hThread = CreateThread(NULL, 0, runThread, NULL, 0, &dwGenericThread);
if (isThreadReady == true)
Beep(523, 200);
CloseHandle(hThread);
return 0;
}
DWORD WINAPI runThread(LPVOID args)
{
isThreadReady = true;
//Beep(523, 200);
return 0;
}