[C++] 纯文本查看 复制代码// 线程A 方法
DWORD WINAPI print_a(LPVOID lpParameter){
for (int i = 0; i < 10; i++){
Sleep(1);
std::cout << "aaa\n";
}
return 0;
}
// 线程B 方法
DWORD WINAPI print_b(LPVOID lpParameter){
for (int i = 0; i < 20; i++){
Sleep(1);
std::cout << "bbb\n";
}
return 0;
}
#define _TCHAR char
#define _tmain main
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE t0, t1;
// 创建线程A
t0 = CreateThread(NULL, 0, print_a, NULL, 0, NULL); //创建线程
t1 = CreateThread(NULL, 0, print_b, NULL, 0, NULL); //创建线程
CloseHandle(t0); //关闭线程句柄对象
CloseHandle(t1);
getchar();
return 0;
}