First of all, what is the difference between thread and pthread. What should I use with in C++.
I am trying with pthread as follows:
//MyPatcher.h
class MyPatcher
{
public:
void createThread();
private:
void * Checkingdata(void *arg);
}
// MyPatcher.cpp
#include "MyPatcher.h"
#include <pthread.h>
using namespace std;
void MyPatcher::createThread()
{
pthread_t threadDataReading;
if(pthread_create(&threadDataReading, NULL, Checkingdata, NULL))
printf("Could not create thread\n");
if(pthread_join(threadReadingGps, NULL))
printf("Could not join thread\n");
}
void * MyPatcher::Checkingdata(void *arg)
{
return NULL;
}
but I run to these problems:
./MyPatcher.cpp:71:73: error: argument of type 'void* (SampleApp::MyPatcher::)(void*)' does not match 'void* (*)(void*)'
How can I solve this problem?
// I then try with thread as well:
//MyPatcher.h
class MyPatcher
{
public:
void createThread();
private:
void Checkingdata();
}
// MyPatcher.cpp
#include "MyPatcher.h"
#include <thread>
using namespace std;
void MyPatcher::createThread()
{
pthread_t threadDataReading(Checkingdata);
threadDataReading.join();
}
void MyPatcher::Checkingdata()
{
}
but I got this problem: error: no matching function for call to 'std::thread::thread()'