Marc Speck wrote: > Actually, this internal field is the source of a potential data race: thread > A runs up to the point, when it has constructed LocatorFactoryImplEx but has > not yet assigned the internal field. Thread A gets on hold relative to > thread B. B runs through the getter and sees that locatorFactory is not > null, fetches the object, access the uninitialized internal field and voilĂ ! > We have a mess.
the revised memory model in java 1.5 guarantees that final fields are properly assigned after the constructor finishes. other threads accessing the constructed locator factory instance will always see the correct field value. see: http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#finalWrong regards marcel
