For example: class Parent{ Mutex lock; String mydata; virtual void DoSomething(){ for(int i=0;i<10;++i){ Cout() << mydata << "\n;" } }; }; class Child1{ void DoSomething(){ INTERLOCKED_(lock){ mydata = "Foo"; Parent::DoSomething(); } } }; class Child2{ void DoSomething(){ INTERLOCKED_(lock){ mydata = "Bar"; Parent::DoSomething(); } } }; CONSOLE_APP_MAIN{ Parent * c1 = new Child1(); Parent * c2 = new Child2(); Thread().Run(callback(&c1, &Parent::DoSomething); Thread().Run(callback(&c2, &Parent::DoSomething); delete c1; delete c2; }
For example: class Parent{ Mutex lock; String mydata; virtual void DoSomething(){ for(int i=0;i<10;++i){ Cout() << mydata << "\n;" } }; }; class Child1{ void DoSomething(){ INTERLOCKED_(lock){ mydata = "Foo"; Parent::DoSomething(); } } }; class Child2{ void DoSomething(){ INTERLOCKED_(lock){ mydata = "Bar"; Parent::DoSomething(); } } }; CONSOLE_APP_MAIN{ Parent * c1 = new Child1(); Parent * c2 = new Child2(); Thread().Run(callback(&c1, &Parent::DoSomething); Thread().Run(callback(&c2, &Parent::DoSomething); delete c1; delete c2; }
class X { static Mutex lock_for_A; static Value A; void function_to_process_A() { // ... using that Mutex *HERE* } };