
18 Apr
2012
18 Apr
'12
1:21 a.m.
Hi all, If I do the following ---------------------------------------------------------------------------------------------------------- shared_ptr<int> pA( new int(1) ); shared_ptr<int> pB( new int(2) ); shared_ptr<int> pNew( new int(3) ); // thread A pA = pB; // thread B pB = pNew; ---------------------------------------------------------------------------------------------------------- I know that whether pA will be int(2) or int(3) after execution is undefined, but if I do want to do this no matter what value of pA I get, will this cause atomicity problem? I mean, thread A increases counter for int(2), but thread B decrease it, is this thread safe? Yuanlong Shao