H***@gmail.com
2005-07-15 07:47:38 UTC
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.
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);
/**************************************************************/
pthread_create(&thrd, &attr, /*????????*/, NULL);
/**************************************************************/
pthread_attr_destroy(&attr);
}
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.
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);
/**************************************************************/
pthread_create(&thrd, &attr, /*????????*/, NULL);
/**************************************************************/
pthread_attr_destroy(&attr);
}
pthread_create(...)'s Syntax
#include <pthread.h>;
int pthread_create (pthread_t *thread, const pthread_attr_t *attr, void
*(*start_routine) (void *), void *arg) ;