【发布时间】:2010-05-26 19:03:36
【问题描述】:
ThreadFunc() 在这里被调用了两次吗?有时我注意到一个电话,有时根本没有。
#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 . . .
【问题讨论】:
标签: winapi multithreading