Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: SingletonFactory and safe publication Date: Mon, 08 Dec 2014 08:48:18 +0100 Lines: 29 Message-ID: References: <547e50bb$0$304$14726298@news.sunsite.dk> <547fc820$0$296$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: individual.net 7svy+k2dZ7uWtD04oJGTeAYLz7XQlo56OMRbcr8bCWpYpsKEs= Cancel-Lock: sha1:PUW07Vuct5DVt6HJSmnmt924jPU= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: <547fc820$0$296$14726298@news.sunsite.dk> Xref: csiph.com comp.lang.java.programmer:30508 On 04.12.2014 03:34, Arne Vajh=C3=B8j wrote: > I have a strong feeling that all the effort "optimizing" singleton > pattern is ridiculous compared to the significance of the problem. > > This has been discussed over and over again by some of the > brightest Java people for more than a decade. > > And I have never heard of a case where the trivial solution > of making the getInstance method synchronized was shown > to actually have a significant negative impact on application > performance. I second that. Plus, if it _does_ have an impact then initializing the=20 instance at the time the factory instance is created and removing the=20 synchronization usually is the best solution. Granted, the instance may = be created prematurly but if the synchronization has an impact then it's = because there are so many accesses to the singleton throughout a long=20 running program - in that case a bit of lag during application start is=20 often negligible if the application runs faster then. Kind regards robert