in reply to threads::shared - when to lock a hash ?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: threads::shared - when to lock a hash ?
by dave_the_m (Monsignor) on Oct 16, 2011 at 09:30 UTC | |
by zwon (Abbot) on Oct 16, 2011 at 14:26 UTC | |
by dave_the_m (Monsignor) on Oct 17, 2011 at 06:53 UTC | |
by ikegami (Patriarch) on Oct 17, 2011 at 03:43 UTC | |
by dave_the_m (Monsignor) on Oct 17, 2011 at 06:47 UTC | |
by ikegami (Patriarch) on Oct 17, 2011 at 06:57 UTC | |
by choroba (Cardinal) on Oct 17, 2011 at 10:30 UTC |