Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<iostream>
  2. #include<thread>
  3.  
  4. using namespace std;
  5.  
  6. static int value;
  7.  
  8. int first()
  9. {
  10. std::cout<<std::endl<<" I am first one !"<<std::endl;
  11. std::cout<<" Give me something = ";
  12. cin>>value;
  13. return 0;
  14. }
  15.  
  16.  
  17. int second()
  18. {
  19. std::cout<<std::endl<<" I am second one !"<<std::endl;
  20. // temporizare
  21. int testing;
  22. std::cin>>testing;
  23. std::cout<<" - > "<<value;
  24. return 0;
  25. }
  26.  
  27. int main()
  28. {
  29. thread sample_1(first);
  30. thread sample_2(second);
  31. // first si second ruleaza concurent !
  32. sample_1.join();
  33. sample_2.join();
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement