Results 1 to 2 of 2
  1. #1
    anandjain1984 is offline Member
    Join Date
    Dec 2009
    Rep Power

    Default using singleton pattern in java

    Can you give me the scenarios where Singleton pattern is used in Java?

  2. #2
    FON is offline Senior Member
    Join Date
    Dec 2009
    Belgrade, Serbia
    Rep Power


    This are common situations where you need only one of kind object:
    DB connection pools, all kind of thread pools, object that work with drivers for devices,
    objects that has to manage concurrent work with shared resources,
    logging service is typical example,
    reading conf file at program start-up that has to be read only once.

    If you create more than one of this objects,
    it can lead you to overuse of some resource that is limited,
    or incorrect and inconsistent results and states in your logic.

    Looking from outside world, every module or part of application will use
    Singleton class exactly the same way, and in all scenarios only one instance
    of this class is ever needed. They have global access nature.


Similar Threads

  1. Replies: 2
    Last Post: 10-06-2008, 10:06 PM
  2. Singleton Pattern
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-24-2008, 04:21 PM
  3. singleton pattern
    By Peter in forum Advanced Java
    Replies: 1
    Last Post: 07-09-2007, 05:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts