> > It probably wasn't very clear from my simplified example, but I'm looking 
> > to create a shared-reader-one-writer scenario. If I declare MyValue 
> > synchronized, only one thread can be inside the get() method at a time, 
> > which defeats the shared-reader requirement. Imagine this is a much larger 
> > more complex data structure, where get() requires walking through multiple 
> > levels of a tree and a binary search at the last level.
> > 
> 
> Yup, I get it. But there is one point in it: write is not atomic operation in 
> sense that get() might return half written data, right?

No, that's why I want a read-write lock. Multiple threads can read the data, 
but writes take an exclusive lock.

http://en.wikipedia.org/wiki/Readers-writer_lock

Reply via email to