It has been said a long time ago that the pointer of C ++ to the class member function is very abnormal. If you want to use the class member function as the parameter of the thread pthread_create, it will be more complicated!
Class {
Public:
Void run (){
}
Static void * run_helper (void * arg ){
(A *) arg)-> run ();
Return (void *) NULL;
}
};
A;
Pthread_t t;
Pthread_create (& t, NULL, & A: run_helper, & );
We wanted to use a. run as the parameter. Therefore, we must create a static run_helper () function and call run (). www.2cto.com in run_helper ().
Related posts:
Programming of TCP/IP exponential growth and linear growth
Function pointer in C ++
C # encapsulate log4net
Use ServletContextListener to create and disable the cache when the server is started and closed
How to Use ServletContextListener
The article you are reading is: C ++ member function as the pthread_create Parameter