A bit OT ... > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On > Behalf Of Maxim Shafirov > Sent: 28 March 2002 16:59 > To: Cedric ROUVRAIS > Subject: Re: [Eap-list] 614: Code Inspection, constant conditions & NPEs > > Hello Cedric, > > This topic had already been discussed in eap several days ago. As the > matter of fact double synchronization does not makes what it intended > to in the current implementation of JVM.
Agreed (although it has always worked for me). In your case, the best way to go might simply not to have any synchronization ... You could do this by initializing your thread safe (singletons) components at initialization time (if you were using servlets you would do it in init(), etc). That would work for your getInstance() but it won't work for any access to shared resources, in which case you would need a semaphore... -Vincent > > -- > Best regards, > Maxim Shafirov > JetBrains, Inc / IntelliJ Software > http://www.intellij.com > "Develop with pleasure!" > > CR> Hi, > > CR> The following code comes out as always false (second 'if (null)'): > > CR> public static ServiceManager getInstance() throws RaccoonException { > CR> if (mServiceManager == null) { > CR> synchronized(ServiceManager.class) { > CR> /** We check if the singleton is still null */ > CR> if (mServiceManager == null) { <= Code inspection yells here > CR> mServiceManager = new ServiceManager(); > CR> mServiceManager.setPropertyFileName("service"); > CR> /** Initialise the ServiceLoader */ > CR> mServiceManager.start(); > CR> } > CR> } > CR> } > CR> return mServiceManager; > CR> } > > CR> Maybe a special case could be handled for code surrounded by > synchronized? > > CR> This is a very very low priority too me, but a nice to have :o) > > CR> a++ Cedric > > CR> _______________________________________________ > CR> Eap-list mailing list > CR> [EMAIL PROTECTED] > CR> http://www.intellij.com/mailman/listinfo/eap-list > > > _______________________________________________ > Eap-list mailing list > [EMAIL PROTECTED] > http://www.intellij.com/mailman/listinfo/eap-list _______________________________________________ Eap-list mailing list [EMAIL PROTECTED] http://www.intellij.com/mailman/listinfo/eap-list
