Hi,
I´m using a class that encapsulates a thread_group, and have some questions about it
class MyGroup{
private:
boost::this_thread::id _id;
boost::thread::thread_group group;
int abc;
//other attributes
public:
void foo();
};
In the class constructor, i launch N threads
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?
}
So, here are my questions.
Do class attributes need to be synchronized?
Do every thread get a different id? For example, if I have
void bar(){
this->id_;
}
will this result in different ids for each thread, or the same for everyone?
Thanks in advance !