thread_groupをカプセル化するクラスを使用していますが、いくつか質問があります
class MyGroup{
private:
boost::this_thread::id _id;
boost::thread::thread_group group;
int abc;
//other attributes
public:
void foo();
};
クラスコンストラクターで、N個のスレッドを起動します
for (size_t i=0;i<N;i++){
group.add(new boost::thread(boost::bind(&foo,this)));
}
void foo(){
_id = boost::this_thread::get_id();
//more code.
abc++ //needs to be sync?
}
それで、ここに私の質問があります。
クラス属性を同期する必要がありますか?
すべてのスレッドは異なるIDを取得しますか?たとえば、私が持っている場合
void bar(){
this->id_;
}
これにより、スレッドごとに異なるIDが生成されますか、それともすべてのスレッドで同じになりますか?
前もって感謝します !