版权声明:本文可能为博主原创文章,若标明出处可随便转载。 https://blog.csdn.net/Jailman/article/details/85322164
#include "pch.h"
#include <iostream>
#include <windows.h>
using namespace std;
typedef struct MyData
{
const char* str;
}MYDATA;
DWORD WINAPI Fun(LPVOID lpParamter)
{
MYDATA *pmd = (MYDATA *)lpParamter;
for (int i = 0; i < 10; i++)
{
cout << "Displaying " << pmd->str << endl;
Sleep(500);
}
return 0;
}
int main()
{
MYDATA xstr;
xstr.str = "你好!";
HANDLE hThread = CreateThread(NULL, 0, Fun, &xstr, 0, NULL);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
cout << "Child thread is over." << endl;
return 0;
}
参考文章:
https://www.cnblogs.com/XiHua/p/5028329.html