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

    Default using singleton pattern in java

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

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

    Default

    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.

    regards:)

Similar Threads

  1. Replies: 2
    Last Post: 10-06-2008, 09:06 PM
  2. Singleton Pattern
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-24-2008, 03:21 PM
  3. singleton pattern
    By Peter in forum Advanced Java
    Replies: 1
    Last Post: 07-09-2007, 04: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
  •