H
Huskier
Hi all:
I want to pass a class-member function to pthread_create, and my
code is in the following, but I don't know how to pass
myobj.thread_function to pthread_create function.
#include <pthread.h>
class test
{
public:
test(){}
~test(){}
void thread_function(void*){}
};
int main()
{
test myobj;
pthread_t thrd;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/**************************************************************/
/* How to pass myobj.thread_function(NULL) to pthread_create(...)*/
pthread_create(&thrd, &attr, /*????????*/, NULL);
/**************************************************************/
pthread_attr_destroy(&attr);
}
the pthread_create(...)'s Syntax
#include <pthread.h>;
int pthread_create (pthread_t *thread, const pthread_attr_t *attr, void
*(*start_routine) (void *), void *arg) ;
I want to pass a class-member function to pthread_create, and my
code is in the following, but I don't know how to pass
myobj.thread_function to pthread_create function.
#include <pthread.h>
class test
{
public:
test(){}
~test(){}
void thread_function(void*){}
};
int main()
{
test myobj;
pthread_t thrd;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/**************************************************************/
/* How to pass myobj.thread_function(NULL) to pthread_create(...)*/
pthread_create(&thrd, &attr, /*????????*/, NULL);
/**************************************************************/
pthread_attr_destroy(&attr);
}
the pthread_create(...)'s Syntax
#include <pthread.h>;
int pthread_create (pthread_t *thread, const pthread_attr_t *attr, void
*(*start_routine) (void *), void *arg) ;