I believe that it is better to create a thread creation in a separate member function as follows:
class Devemu {
...
void run()
{
pthread_create(&thread_id, NULL, &Devemu::IncWrapper, NULL);
}
...
};
Not really in ctor, because sometimes you (or anyone who uses your code) can forget this thread created in ctor and start coding, for example:
Devemu m;
...
Devemu m1;
...
creates unnecessary threads, like instances of a class.
source
share