1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | class Thread { public: // start the thread void start () { ACE_Thread::spawn(&Thread::do_run, this); } // must be overridden by derived class; runs in the new thread virtual void run () = 0; protected: // protected so class cannot be instantiated except by derived class virtual ~Thread () { } private: // callback provided to thread library; simply defers to member function static void *do_run (void *p) { Thread *thread = static_cast<Thread *>(p); thread->run(); return 0; } }; |