All pastes #77626 Raw Edit

Stuff

public cpp v1 · immutable
·published 2006-07-03 06:22 UTC
rendered paste body
#include <iostream>#include <pthread.h>using namespace std;class CThread {   public:      CThread() {};      virtual ~CThread() {};      int Create(void *arg);      int Join(void **ppvalue);   protected:      static void *EntryPoint(void *);      virtual void Execute(void *arg);      void *Arg() const {return m_arg;}      void Arg(void *a) {m_arg = a;}   private:      pthread_t m_threadId;      void *m_arg;};int CThread::Create(void *arg) {   int retval;      Arg(arg);   retval = pthread_create(&m_threadId, NULL, CThread::EntryPoint, this);   return retval;}int CThread::Join(void **ppvalue) {   int retval;      retval = pthread_join(m_threadId, ppvalue);      return retval;}void *CThread::EntryPoint(void *pthis) {   CThread *pt = (CThread *)pthis;   pt->Execute( pt->Arg() );      return NULL;}void CThread::Execute(void *arg) { }class CDemoThread : public CThread {   virtual void Execute(void *arg) {      cout << *(int *)arg << endl;   }};int main(void){   CDemoThread dmt;   int i = 101;      dmt.Create(&i);   dmt.Join(NULL);      return EXIT_SUCCESS;}