2009/3/5 Niclas Hedhman <[email protected]> > I see this snippet of code in ServiceReferenceInstance; > > > private volatile ServiceInstance serviceInstance; > private CompositeInstance instance; > > private CompositeInstance getInstance() > throws ServiceImporterException > { > // DCL that works with Java 1.5 volatile semantics > if( instance == null ) > { > synchronized( this ) > { > if( instance == null ) > { > serviceInstance = serviceModel.newInstance( module ); > CompositeInstance providedInstance = > serviceInstance.instance(); > > if( providedInstance.<T>proxy() instanceof Activatable ) > { > try > { > activator.activate( (Activatable) > providedInstance.proxy() ); > } > catch( Exception e ) > { > serviceInstance = null; > throw new ServiceImporterException( e ); > } > } > > instance = providedInstance; > } > } > } > > Is the volatile keyword really on the right variable here?? >
doesn't look right to me - the volatile should be on the instance variable to get the correct semantics Cheers > Niclas > -- > http://www.qi4j.org - New Energy for Java > > _______________________________________________ > qi4j-dev mailing list > [email protected] > http://lists.ops4j.org/mailman/listinfo/qi4j-dev > -- Cheers, Stuart
_______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

