#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
int i = 0;
DWORD WINAPI ThreadProc1(LPVOID lpParam)
{
while (1)
{
char buf[100] = {};
sprintf(buf, "这是线程%d", i);
MessageBox(NULL,buf,"测试",NULL);
++i;
CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadProc1, // thread function
NULL, // argument to thread function
0, // use default creation flags
NULL);
Sleep(2000);
}
}
void main()
{
//创建线程1
CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadProc1, // thread function
NULL, // argument to thread function
0, // use default creation flags
NULL); // returns the thread identifier
getchar();
}
线程
最新推荐文章于 2024-03-27 14:44:09 发布