`
futrueboy
  • 浏览: 83706 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

c++类中多线程的使用

阅读更多
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <windows.h>
class Instance
{
public:
	Instance() 
	{	
		this->thread();
	};
	
private:
	static int num;
	static void run(int num)
	{
		printf("%d", num);
	};
	void thread();
};

int Instance::num = 1;


void Instance :: thread()
{
	CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)run, (LPVOID)this->num, 0, NULL);
}

int main (int argc, char *argv[])
{
	Instance instance;
	system ("pause");
	return 0;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics