Create a thread demo

来源:互联网 发布:mysql minpoolsize 编辑:程序博客网 时间:2024/04/25 16:46
//----------------------------------------------// Time: 2016-7-6// Author: Mancor// Description: Create a thread Test//----------------------------------------------#include "stdafx.h"#include <process.h>DWORD WINAPI ThreadProc(LPVOID lpParam){    while(1)    {        printf("I am the sub thread, GetCurrentThread:%d \r\n",GetCurrentThread());        Sleep(500);    }    return 0;}int _tmain(int argc, _TCHAR* argv[]){    printf("Test: Main Thread Start.\r\n");    DWORD dwThreadId = 0;    CreateThread(NULL, 0, ThreadProc, NULL, 0, &dwThreadId);    char szBuf[128]={0};    sprintf_s(szBuf, " File: %s, Function: %s, Line: %d \r\n",__FILE__,__FUNCTION__,__LINE__);    printf(szBuf);    while(1)        Sleep(5);    return 0;}
0 0