rendered paste body#include <cstdlib>#include <iostream>#include <windows.h>using namespace std;void thread1();void thread2();void thread3();void thread4();int main(int argc, char *argv[]){ HANDLE tFirst, tSecond, tThird, tFourth; DWORD ThreadID; tFirst = CreateThread( // Generic function from "Windows.h". NULL, // Security Attributes. (NULL -> Use Default). 0, // StackSize. (0 -> Use Default). (LPTHREAD_START_ROUTINE)thread1, // POINTER TO START-FUNCTION. (TypeCasted). NULL, // Parameter for start function (if needed). CREATE_SUSPENDED, // (CREATE_SUSPENDED -> Don't start thread yet). &ThreadID); tSecond = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread2, NULL, CREATE_SUSPENDED, &ThreadID); tThird = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread3, NULL, CREATE_SUSPENDED, &ThreadID); tFourth = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread4, NULL, CREATE_SUSPENDED, &ThreadID); // Start (Technically "resume") threads. ResumeThread(tFirst); ResumeThread(tSecond); ResumeThread(tThird); ResumeThread(tFourth); HANDLE ThreadContainer[4]; ThreadContainer[0] = tFirst; ThreadContainer[1] = tSecond; ThreadContainer[2] = tThird; ThreadContainer[3] = tFourth; DWORD dwSuccess = WaitForMultipleObjects(2, // Number of threads in array. ThreadContainer, // The array TRUE, // (TRUE -> Wait for ALL threads). INFINITE); // Wait forever. if (dwSuccess == WAIT_FAILED) cout << "wait failed." << endl; else cout << "success!" << endl; system("PAUSE"); return EXIT_SUCCESS;}void thread1(){ cout << "thread1 reporting in." << endl; return;}void thread2(){ cout << "thread2 reporting in." << endl; return;}void thread3(){ cout << "thread3 reporting in." << endl; return;}void thread4(){ cout << "thread4 reporting in." << endl; return;}