Hi I have the following C++ code,
I have MyThread class in the thread.h file
class MyThread
{
public:
void start();
virtual void* task() = 0;
};
I have worker class in the worker.h file
class Worker : public MyThread
{
virtual ~Worker();
virtual void* task(); // I have implementation in worker.cpp
};
Have used pthread_create()
in the start()
in thread.cpp
file for creating a thread and I want to make the task()
routine defined in the worker.cpp
as the start routine . So how can I do that ? What should I pass as the parameter to the start routine in pthread_create
?
I have tried this but it gives an error:
pthread_create(&(this->threadId),&(this->attr),(void *)task,NULL);