Creating Thread in Win32

Posted by Dave18 on Stack Overflow See other posts from Stack Overflow or by Dave18
Published on 2010-05-26T19:03:36Z Indexed on 2010/05/26 19:11 UTC
Read the original article Hit count: 203

Filed under:
|

Does ThreadFunc() gets called two times here? sometimes I notice a single call and sometimes none at all.

#include <windows.h>
#include <stdio.h>

DWORD WINAPI ThreadFunc(LPVOID);

int main()
{
    HANDLE hThread;
    DWORD threadld;

    hThread = CreateThread(NULL, 0, ThreadFunc, 0, 0, &threadld );
    printf("Thread is running\n");
}

DWORD WINAPI ThreadFunc(LPVOID p)
{
    printf("In ThreadFunc\n");
    return 0;
}

Output 1

Thread is running
In ThreadFunc
In ThreadFunc
Press any key to continue . . .

Output 2

Thread is running
In ThreadFunc
Press any key to continue . . .

Output 3

Thread is running
Press any key to continue . . .

© Stack Overflow or respective owner

Related posts about win32

Related posts about threads