博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C++多线程

Posted on 2011-04-03 13:20  信徒.1  阅读(169)  评论(0)    收藏  举报
#include <iostream>
#include <windows.h>

using namespace std;

//函数定义
DWORD WINAPI FunProc(LPVOID lpParamter);

int index=0;
void main(){

	HANDLE hThread1;
	hThread1=CreateThread(NULL,0,FunProc,NULL,0,NULL);
	CloseHandle(hThread1);
	while(index++<1000){
		cout<<"Main Thread is running"<<endl;
	}
	
	
}

DWORD WINAPI FunProc(LPVOID lpParamter){
	while(index++<1000){
		cout<<"Thread1 is running"<<endl;
	}
	return 0;
}