码迷,mamicode.com
首页 > 编程语言 > 详细

C++创建带有参数输入的多线程

时间:2015-11-03 12:43:03      阅读:387      评论:0      收藏:0      [点我收藏+]

标签:

#include "stdafx.h"

#include <iostream>

#include <windows.h>

using namespace std;


struct test{

char name[100];

};

 

DWORD WINAPI Fun(LPVOID lpParamter)

{

//test* t = (test*)lpParamter;

char *c = (char *)lpParamter;

for(int i = 0;i<10;i++){ cout << c<<"Fun display!"<<endl; Sleep(2000);}

return NULL;

}

 

int main()

{

/*test *t1 = new test();

strcpy_s(t1->name,"子线程");*/

    HANDLE hThread = CreateThread(NULL, 0, Fun, "子线程", 0, NULL);


    CloseHandle(hThread);

    for(int i = 0;i<10;i++){ cout<<"main display!"<<endl; Sleep(1000);}

//delete t1;

cin.get();

    return 0;

}


C++创建带有参数输入的多线程

标签:

原文地址:http://my.oschina.net/kkkkkk/blog/525151

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!