Explain Singleton Pattern Could you please give me the Pseudocode for singleton pattern

Posted on 2011-10-18
Last Modified: 2013-11-24
Explain Singleton Pattern Could you please give me the Pseudocode for singleton pattern
Question by:stmani2005
    LVL 4

    Expert Comment

    LVL 4

    Accepted Solution

    Even better is to use the singleton this way, now it is thread save:

    public class Singleton {
            // Private constructor prevents instantiation from other classes
            private Singleton() { }
            * SingletonHolder is loaded on the first execution of Singleton.getInstance() 
            * or the first access to SingletonHolder.INSTANCE, not before.
            private static class SingletonHolder { 
                    public static final Singleton instance = new Singleton();
            public static Singleton getInstance() {
                    return SingletonHolder.instance;

    Open in new window

    LVL 20

    Expert Comment

    by:Sathish David Kumar N

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now