Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : Uenal Mutlu Date : Wed May 18 2005 05:48 pm The following can be replaced: /* // intermediate helper for Locker and RLocker below: template class LockerT { public: LockerT(mutexT& Am) : m(Am) { m.lock(); } ~LockerT() { m.unlock(); } private: mutexT& m; }; class Locker : public LockerT { public: Locker(mutex& Am) : LockerT(Am) {} }; class RLocker : public LockerT { public: RLocker(rmutex& Am) : LockerT(Am) {} }; */ by this: class Locker { public: Locker(mutex& Am) : m(Am) { m.lock(); } ~Locker() { m.unlock(); } private: mutex& m; }; Locker then can be used for both mutex and rmutex. This is because rmutex is derived from mutex. .