Skip to content

Instantly share code, notes, and snippets.

@mkamilov
Created November 15, 2017 15:56
Show Gist options
  • Save mkamilov/b5ee19a0ab24f1690b6ffcbbafe51be4 to your computer and use it in GitHub Desktop.
Save mkamilov/b5ee19a0ab24f1690b6ffcbbafe51be4 to your computer and use it in GitHub Desktop.
#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