Created
November 15, 2017 15:56
-
-
Save mkamilov/b5ee19a0ab24f1690b6ffcbbafe51be4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment