[concurrency-interest] Reading a volatile vs uncontented lock

thurston at nomagicsoftware.com thurston at nomagicsoftware.com
Wed Feb 13 11:36:14 EST 2013


Hello,

I was wondering what requires more overhead: reading a volatile 
reference or obtaining a lock when there is no contention.

Essentially I have a single-reader scenario, where the common-path 
(99%+) doesn't require either a volatile read or a lock; but if I want 
to support a few very-rarely used cases, I can only make it thread-safe 
by making the 99% case rely on a volatile read or obtain a lock.
Any guidelines?

Thanks



More information about the Concurrency-interest mailing list