Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <thread>
- using namespace std;
- class copyClass
- {
- public:
- int index;
- };
- class SayHello
- {
- private:
- public:
- copyClass hallos;
- SayHello( )
- {
- }
- void set(copyClass classchange)
- {
- hallos=classchange;
- }
- void print()
- {
- for(int i=0;i<10000000;i++)
- cout<<"indez "<<hallos.index<<endl;
- }
- void operator()()
- {
- print();
- }
- };
- int main() {
- copyClass indexing;
- indexing.index=0;
- SayHello hallo;
- hallo.set(indexing);
- thread td0(hallo);
- SayHello hallo1;
- indexing.index=1;
- hallo1.hallos=indexing;
- thread td1(hallo1);
- cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
- td0.join();
- td1.join();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement