Is this thread safe?

Walter Bright newshound1 at digitalmars.com
Fri Jul 11 16:06:33 PDT 2008


dsimcha wrote:
> I'm very new to concurrent programming and am trying to implement some high
> performance math stuff in D.  Could someone please tell me whether the
> following simple function would be considered thread safe?

No, it is not thread safe. It's the old double checked locking problem. 
The reasons are difficult to understand, but understanding it is crucial 
to writing thread safe code.

http://www.ddj.com/184405726

http://en.wikipedia.org/wiki/Double_checked_locking_pattern



More information about the Digitalmars-d mailing list