Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- //#include <stdlib.h>
- #include <malloc.h>
- VOID Messages(VOID);
- VOID MultiThread(VOID);
- DWORD WINAPI WorkThread0(LPVOID param);
- DWORD WINAPI WorkThread1(LPVOID param);
- DWORD WINAPI WorkThread2(LPVOID param);
- ///////////////////////////////////////////////////// 4
- int main() //
- {
- //Messages();
- MultiThread();
- return 0;
- }
- /////////////////////////////////////////////////////
- VOID MultiThread(VOID) //
- {
- HANDLE hArr[3];
- hArr[0] = CreateThread(NULL, 0, WorkThread0, NULL, 0, 0);
- hArr[1] = CreateThread(NULL, 0, WorkThread1, NULL, 0, 0);
- hArr[2] = CreateThread(NULL, 0, WorkThread2, NULL, 0, 0);
- WaitForMultipleObjects(3, hArr, TRUE, INFINITE);
- //WARNING! Íóæåí ìàêðîñ INFINITE à íå INFINITY
- //Æäàòü 1 ïîòîê
- //WaitForSingleObject(hArr[0], INFINITE);
- for(int i = 0; i < 3; ++i) CloseHandle(hArr[i]);
- }
- /////////////////////////////////////////////////////
- DWORD WINAPI WorkThread0(LPVOID param) //
- {
- for (int i = 0; i < 50; ++i)
- printf("Message 0: %d\n", i);
- ExitThread(0);
- }
- DWORD WINAPI WorkThread1(LPVOID param)
- {
- for (int i = 0; i < 50; ++i)
- printf("Message 1: %d\n", i);
- ExitThread(0);
- }
- DWORD WINAPI WorkThread2(LPVOID param)
- {
- for (int i = 0; i < 50; ++i)
- printf("Message 2: %d\n", i);
- ExitThread(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement