Track Performance of Distributed Systems


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Track Performance of Distributed Systems

  1. #1
    Roy Lachapelle Guest

    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

  2. #2
    Chris P. Guest

    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




  3. #3
    Brian Maso Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center