まず、thread と pthread の違いは何ですか。C++ で何を使用する必要がありますか。
次のようにpthreadを試しています:
//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;
}
しかし、私はこれらの問題に遭遇します:
./MyPatcher.cpp:71:73: error: argument of type 'void* (SampleApp::MyPatcher::)(void*)' does not match 'void* (*)(void*)'
どうすればこの問題を解決できますか?
// 次に、スレッドも試します。
//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()
{
}
しかし、私はこの問題を抱えています:エラー:「std::thread::thread()」への呼び出しに一致する関数はありません