---
title: "c++类中多线程的使用"
author: "futrueboy"
date: "2008-09-14T14:13:15Z"
tags: []
slug: "c"
draft: false
lastmod: "2008-09-14T14:13:15Z"
id: 241583
url: "https://futrueboy.iteye.com/blog/241583"
---

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