0

重複の可能性:
クラスからの pthread 関数

クラスで pthread を使用する方法を理解できるように、誰でも簡単な例を挙げてもらえますか?

インターネットの例は複雑すぎて、概念がわかりません。

クラスを使用しないときのコードを書きました。

編集:

次のようなものをコンパイルする必要があります。

#include<stdio.h>
#include<pthread.h>
using namespace std;
class test
{
private:
    int i = 0;
public:

static void *fun()
{
    i = i+1;
    cout << i<< endl;
}
};

int main()
{
pthread_t th;
test newTest;
pthread_create(&th, NULL, newTest.fun, NULL);
}
4

0 に答える 0