FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Dobbs M-Dev
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
April 01, 2003

Memory Consistency & .NET

(Page 4 of 10)
Apr03: Memory Consistency & .NET


(a)
lock( ... ) 
   if( Z==null )
      Z = new Foo();
 ... = Z;

(b)
// Z must be declared volatile
if( Z==null ) 
   lock( ... ) 
      if( Z==null )
         Z = new Foo();
 ... = Z

Example 3: Double check is an optimization of lazy initialization that avoids acquiring a lock in the common case that Z is already initialized. (a) Lazy initialization; (b) double check.

Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK