thread.h revision 496cc45c1fbfb86e236b3943fc198553fec983b5
1#ifndef __THREAD_H 2#define __THREAD_H 3 4#include <pthread.h> 5 6class RunnableInterface { 7public: 8 RunnableInterface() {}; 9 virtual ~RunnableInterface() {}; 10 11 virtual void Run(void) = 0; 12}; 13 14class Thread : public RunnableInterface { 15public: 16 Thread(); 17 Thread(RunnableInterface *r); 18 ~Thread(); 19 20 int Start(void); 21 int Join(void); 22 23protected: 24 /* 25 * overriden by the derived class 26 * when the class is derived from Thread class 27 */ 28 virtual void Run(void); 29 30private: 31 static void *Instance(void *); 32 33 RunnableInterface *r; 34 pthread_t id; 35}; 36 37#endif /* __THREAD_H */ 38