-
Track Performance of Distributed Systems
In the Downloadable examples, Masocode.zip, the java code for Syslog.java
has a method:
public static synchronized Syslog instance() {
if (instance != null)
instance = new Syslog();
return instance;
}
Shouldn't that be ' if (instance == null) ' to perform as a 'hybrid' singleton
?
(I say 'hybrid' because the constructor is not private...)
And even if a new instance was desired each time, then the instance needs
to be
initialized somewhere, possibly in the constructor.
-Roy
-
Re: Track Performance of Distributed Systems
"Roy Lachapelle" <Roy.Lachapelle@Travelersla.com> wrote:
>
>In the Downloadable examples, Masocode.zip, the java code for Syslog.java
>has a method:
>
>public static synchronized Syslog instance() {
> if (instance != null)
> instance = new Syslog();
> return instance;
> }
>
>Shouldn't that be ' if (instance == null) ' to perform as a 'hybrid'
singleton
>?
>(I say 'hybrid' because the constructor is not private...)
>
>And even if a new instance was desired each time, then the instance needs
>to be
>initialized somewhere, possibly in the constructor.
>
>-Roy
thanks for your question. I've alerted Brian to this, and he should be posting
an answer shortly.
/cp
devX.com
-
Re: Track Performance of Distributed Systems
[From the author, Brian Maso]
Yes, Roy is exactly correct. I should have checked this part of the code,
which was not exercised in the sample program.
The idea of the single instance would be for an application that has maby
different components sending syslog messages off. Rather than have each one
create an independent Syslog instance (with all the resource expence associated),
they can all just share a single stateless Syslog instance available through
the static method.
Of course the static method would have to be written correctly...
Thanks for finding that, Roy. A corrected version of the zip file with be
available soon.
Brian Maso
"Roy Lachapelle" <Roy.Lachapelle@Travelersla.com> wrote:
>
>In the Downloadable examples, Masocode.zip, the java code for Syslog.java
>has a method:
>
>public static synchronized Syslog instance() {
> if (instance != null)
> instance = new Syslog();
> return instance;
> }
>
>Shouldn't that be ' if (instance == null) ' to perform as a 'hybrid'
singleton
>?
>(I say 'hybrid' because the constructor is not private...)
>
>And even if a new instance was desired each time, then the instance needs
>to be
>initialized somewhere, possibly in the constructor.
>
>-Roy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks