#include #include #include // Counting Semaphore initialized to 10 CountingSemaphore sem1; CountingSemaphore sem2(1); class Daughter : public Thread { public: Daughter() { } protected: void Run(void) { while(1) { sem2.P(); cout << "Daughter: Just did a P" << endl; sem1.V(); } } }; int main(void) { Daughter daughter; daughter.Start(); while(1) { sem1.P(); cout << "Mother: Just did a P" << endl; sem2.V(); } Thread::Join(&daughter); return 0; }