1.如何定义多线程中的原子操作
2.多线程的一个经典的例子
(1)编写子线程函数
DWORD WINAPI Fun(LPVOID lpParamter)
{
while(1) { cout<<"Fun display!"<<endl;
Sleep(100);
}
}
(2)在Windows平台下用win32自带的createthread函数创建线程
HANDLE hthread=CreateThread(NULL,0,Fun,NULL,0,NULL);
(3)测试
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hthread=CreateThread(NULL,0,Fun,NULL,0,NULL);
//CloseHandle(hthread);
while(1) { cout<<"main display!"<<endl;}
return 0;
}