15.3简单多线程示例
#include <iostream>
#include <Windows.h>
using namespace std;
DWORD WINAPI ThreadProc(LPVOID lpParameter);
int main()
{
DWORD ThreadID;
HANDLE hThread = CreateThread(NULL,0,ThreadProc,NULL,0,&ThreadID);
cout<<"MainThread runs"<<endl;
WaitForSingleObject(hThread,INFINITE);
CloseHandle(hThread);
return 0;
}
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
cout<<"ThreadProc runs"<<endl;
return 0;
}