Advertisement
Cieslin

PRIR_Szablon_Lab_02

Oct 24th, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. // HelloWorldPRIR.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <Windows.h>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. DWORD WINAPI watek(LPVOID lpParam);
  11.  
  12. int main()
  13. {
  14.     DWORD w_id[10];
  15.     HANDLE w_h[10];
  16.  
  17.     for(int i = 0; i < 10; i++)
  18.         if ((w_h[i] = CreateThread(NULL, 0, watek, (LPVOID)i, 0, &w_id[i])) == NULL)
  19.         {
  20.             cout << "Blad w czasie tworzenia watku nr " << i << endl;
  21.             return 1;
  22.         }
  23.         else
  24.         {
  25.             cout << "Utworzono watek o id = " << w_id[i] << endl;
  26.         }
  27.     WaitForMultipleObjects(10, w_h, TRUE, INFINITE);
  28.     for (int i = 0; i < 10; i++)
  29.         CloseHandle(w_h[i]);
  30.     cin.get();
  31.     return 0;
  32. }
  33.  
  34. DWORD WINAPI watek(LPVOID lpParam) {
  35.     cin.get();
  36.     return 1;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement