Advertisement
Guest User

Untitled

a guest
Nov 9th, 2011
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3. using namespace std;
  4. class copyClass
  5. {
  6. public:
  7. int index;
  8. };
  9. class SayHello
  10. {
  11. private:
  12.  
  13.  
  14. public:
  15. copyClass hallos;
  16. SayHello( )
  17. {
  18.  
  19. }
  20. void set(copyClass classchange)
  21. {
  22. hallos=classchange;
  23. }
  24. void print()
  25. {
  26. for(int i=0;i<10000000;i++)
  27. cout<<"indez "<<hallos.index<<endl;
  28. }
  29. void operator()()
  30. {
  31. print();
  32. }
  33. };
  34.  
  35. int main() {
  36. copyClass indexing;
  37. indexing.index=0;
  38. SayHello hallo;
  39. hallo.set(indexing);
  40. thread td0(hallo);
  41. SayHello hallo1;
  42. indexing.index=1;
  43. hallo1.hallos=indexing;
  44. thread td1(hallo1);
  45. cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
  46. td0.join();
  47. td1.join();
  48. return 0;
  49. }
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement