Then, if you have one write and multiple reads to a single scalar, it seems you do not need locking either. Each read either gets the value before the write, or the one after, but not something else. Correct?
No, not correct, you can get inconsistent value in the reading thread. You always have to lock shared variable when you accessing it.
In reply to Re: threads::shared - when to lock a hash ?
by zwon
in thread threads::shared - when to lock a hash ?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |