Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <thread>
- using namespace std;
- void func1()
- {
- cout << "func1 " << endl;
- }
- class MyThreadClass
- {
- private:
- //static thread Th1;
- thread Th1;
- public:
- MyThreadClass() : Th1(func1) {};
- ~MyThreadClass() { Th1.join(); }
- };
- //thread MyClass::Th1(func1);
- class MyObjectClass
- {
- static MyThreadClass mth;
- public:
- MyObjectClass() { cout << "creating object" << endl; }
- };
- MyThreadClass MyObjectClass::mth;
- int main()
- {
- cout << "Hello" << endl;
- MyObjectClass c1;
- MyObjectClass c2;
- return 0;
- }
Add Comment
Please, Sign In to add comment