创建线程

// 05创建线程.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "windows.h"
//指定程序入口函数为MyFun()
//  #pragma comment(linker,"/entry:\"MyFun"")

DWORD  WINAPI   ThreardPro(LPVOID pParam)
{
    int i = 0;
    while (true)
    {
        printf("%d\n",i++);
    }
    return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{

    HANDLE hThread = 
        CreateThread(NULL, 0, ThreardPro, NULL, NULL, NULL);
    //参数1:线程属性
    //参数2:指定线程可以拥有多少栈空间
    //参数3:线程函数起始地址
    //参数4:线程函数参数
    //参数5:线程创建标志
    //参数6:新创建线程的ID
    while (true)
    {
        printf("我是主线程\n");
    }
    return 0;
}

 

posted @ 2016-03-15 18:14  天还是那么蓝  阅读(137)  评论(0编辑  收藏  举报