您的位置:首页 > 其它

Create a thread demo

2016-07-06 08:00 309 查看
//----------------------------------------------
// 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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  线程