If you are responding to Streets of Boston, that code is not doing double check locking. It is doing the only null check with the lock held.
Personally I prefer to explicitly use synchronized() instead of synchronized methods for legibility and to avoid leaking locking semantics out of a class, but that is a separate issue. :) On Fri, Jun 3, 2011 at 9:24 AM, Chris <[email protected]> wrote: > Read "Double-Checked Locking; Clever but Broken" > > http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html > > The pattern, while common, was broken prior to Java 5 and was fixed after > but only if mySingleton is declared volatile. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

