Advertisement
dzieciol

PRiR zajecia1 zadanie 1

Mar 2nd, 2018
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. /*
  8.  * File:   main.cpp
  9.  * Author: student
  10.  *
  11.  * Created on 2 marca 2018, 12:19
  12.  */
  13.  
  14. #include <stdlib.h>
  15. #include <iostream>
  16. #include <boost/thread/thread.hpp>
  17.  
  18. using namespace std;
  19. using namespace boost;
  20. /*
  21.  *
  22.  */
  23. const int opoznienie = 100;
  24. int licznik = 50;
  25.  
  26.  
  27.  
  28.  
  29.  
  30. class Watek{
  31. private:
  32.     int numer;
  33. public:
  34.     Watek(int _numer): numer(_numer){
  35.        
  36.     }
  37.     void operator()(){
  38.         while(licznik > 0){
  39.             cout<<"W:" <<numer <<" L: "<< licznik<< endl;
  40.             --licznik;
  41.             this_thread::sleep_for(chrono::microseconds(opoznienie));
  42.            
  43.         }
  44.     }
  45. };
  46.  
  47. int main2(int argc, char** argv) {
  48.     thread w1(Watek(1));
  49.     thread w2(Watek(2));
  50.    
  51.     w1.join();
  52.     w2.join();
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement