When a class member function creates a thread to invoke another function of a class member, there are two ways to fix it.
The first kind is more troublesome,
For example, there is a class
void* Gstartvod (void* pvoid);
Class record{
Friend void* Gstartvod (void* pvoid);
void Create_pthread_fun (void* pvoid);
void* thread (void* pvoid);
static record *_record;
PTHREAD_ID _threadid;
}
void*
Gsavevideodata (void* pvoid)
{
Record::_record->thread (PVOID);
}
void Record::create_pthread_fun (void* pvoid)
{
Pthread_create (&_threadid, NULL, GSaveVideoData2, pvoid);
}
Set a static pointer variable for the class itself in the class. Defines a global function. For example, to implement a call to a class member.
The second method is simpler, declaring the called Class member function as a static variable.
Class record{
Friend void* Gstartvod (void* pvoid);
void Create_pthread_fun (void* pvoid);
Static void* thread (void* pvoid);
PTHREAD_ID _threadid;
}
void Record::create_pthread_fun (void* pvoid)
{
Pthread_create (&_threadid, NULL, Thread, pvoid);
}