ITeye博客

c++类中多线程的使用

futrueboy · 2008-09-14 14:13 · Markdown


#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;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。