Guest User

Untitled

a guest
Nov 17th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3.  
  4. using namespace std;
  5.  
  6. void func1()
  7. {
  8. cout << "func1 " << endl;
  9. }
  10.  
  11. class MyThreadClass
  12. {
  13. private:
  14. //static thread Th1;
  15. thread Th1;
  16.  
  17. public:
  18. MyThreadClass() : Th1(func1) {};
  19. ~MyThreadClass() { Th1.join(); }
  20. };
  21.  
  22. //thread MyClass::Th1(func1);
  23. class MyObjectClass
  24. {
  25. static MyThreadClass mth;
  26. public:
  27. MyObjectClass() { cout << "creating object" << endl; }
  28. };
  29.  
  30. MyThreadClass MyObjectClass::mth;
  31.  
  32. int main()
  33. {
  34. cout << "Hello" << endl;
  35.  
  36. MyObjectClass c1;
  37. MyObjectClass c2;
  38. return 0;
  39. }
Add Comment
Please, Sign In to add comment