ThreadFunc()在這裏被調用兩次嗎?有時我會注意到一個電話,有時甚至沒有。在Win32中創建線程
#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;
}
輸出1
Thread is running
In ThreadFunc
In ThreadFunc
Press any key to continue . . .
輸出2
Thread is running
In ThreadFunc
Press any key to continue . . .
輸出3
Thread is running
Press any key to continue . . .
請點擊此鏈接:http://stackoverflow.com/questions/601558/multithreading-reference – lsalamon 2010-05-26 19:28:25