Double Checked Locking

Jonathan M Davis jmdavisProg at gmx.com
Sat Dec 17 18:08:39 PST 2011


On Saturday, December 17, 2011 17:10:19 Andrei Alexandrescu wrote:
> On 12/17/11 5:03 PM, Jonathan M Davis wrote:
> > Well, you learn something new every day I guess. I'd never even heard of
> > double-checked locking before this. I came up with it on my own in an
> > attempt to reduce how much the mutex was used. Is the problem with it
> > that the write isn't actually atomic? Wikipedia makes it sound like the
> > problem might be that the object might be partially initialized but not
> > fully initialized, which I wouldn't have thought possible, since I
> > would have thought that the object would be fully initialized and
> > _then_ the reference would be assigned to it. And it's my understanding
> > that a pointer assignment like that would be atomic. Or is there more
> > going on than that, making it so that the assignment itself really
> > isn't atomic?
> 
> There so much going on about double-checked locking, it's not even
> funny. Atomic assignments have the least to do with it. Check this out:
> http://goo.gl/f0VQG

Looks interesting. I'll have to give it a read. I really like te subtitle 
though: "Multithreading is just one damn thing after, before, or simultaneous 
with another."

In any case, I obviously need to learn more about some of the issues with 
multi-threading.

- Jonathan M Davis


More information about the Digitalmars-d mailing list