请问以下程序是2线程,还是3线程?
请问以下程序是2线程,还是3线程?代码还可以再简单点不?程序代码:
//最简单的创建多线程实例 #include <stdio.h> #include <windows.h> //子线程函数 A DWORD WINAPI ThreadFunA(LPVOID pM) { printf("子线程A的线程ID号为:%d\n子线程A输出Hello World\n", GetCurrentThreadId()); return 0; } //子线程函数 B DWORD WINAPI ThreadFunB(LPVOID pM) { printf("子线程B的线程ID号为:%d\n子线程B输出Hello World\n", GetCurrentThreadId()); return 0; } //主函数,所谓主函数其实就是主线程执行的函数。 int main() { printf("最简单的创建多线程实例\n"); HANDLE handleA = CreateThread(NULL, 0, ThreadFunA, NULL, 0, NULL); WaitForSingleObject(handleA, INFINITE); HANDLE handleB = CreateThread(NULL, 0, ThreadFunB, NULL, 0, NULL); WaitForSingleObject(handleB, INFINITE); system("pause"); }