#include <stdio.h>
#include <process.h>
#include <windows.h>
class A
{
public:
void StartThread();
DWORD static WINAPI ThreadFunc(LPVOID lparam);
public:
int abc;
};
void A::StartThread()
{
CreateThread(NULL,NULL,ThreadFunc,this,NULL,NULL);
}
DWORD WINAPI A::ThreadFunc( LPVOID lparam )
{
A* pa=(A*)lparam;
pa->abc=123;
printf("%d\n",pa->abc);
return true;
}
int main (void)
{
A a;
a.StartThread();
getchar();
return 0;
}
/*
2015年5月5日 22:39:46
程序执行结果如下:
123
请按任意键继续. . .
*/
类中使用线程例子4
最新推荐文章于 2022-01-06 21:21:35 发布