On Saturday, December 03, 2011 20:54:38 Andrej Mitrovic wrote: > On 12/3/11, Jonathan M Davis <jmdavisp...@gmx.com> wrote: > > Where in TDPL does it say this? > > Page 413. > > > Requiring that all operations on a shared > > object be atomic would be highly restrictive. > > Yeah sorry, my title was wrong, of course you could use > synchronization instead of atomics. But shared does need to have > guarantees, it should be as useful as, say, const (when it works).
That page says that reads and writes are guaranteed to be atomic for shared. It does _not_ say that something like ++threadsCount is guaranteed to be atomic. That's a read _and_ a write. You have to do something yourself to guarantee that it's treated as atomic across threads (via sychronized blocks, or mutexes, or whatever). - Jonathan M Davis