Problem while creating Singleton
<p>I am trying to create a <code>Singleton</code> class, which will be accessed from two other classes.Can anyone please tell me whats wrong with the following code? I am just not able to figure out!</p>

<pre><code>import java.util.LinkedList;

public class MessageQueue {

    private static final LinkedList&lt;ServerDataEvent&gt; queue = new LinkedList&lt;ServerDataEvent&gt;();;

    private static MessageQueue messageQueue = null;

    /** A private Constructor prevents any other class from instantiating. */
    private MessageQueue() {
    }

    /** Static 'instance' method */
    public static MessageQueue getInstance() {
        if (MessageQueue.messageQueue == null) {
            System.out.println("Creating MessageQueue instance.");
            MessageQueue.messageQueue = new MessageQueue();
        }
        return MessageQueue.messageQueue;
    }

    public Object clone() throws CloneNotSupportedException {
        throw new CloneNotSupportedException();
    }
}
</code></pre>

<p>I am accessing the singleton object from other classes like this:</p>

<pre><code>MessageQueue messageQueue = MessageQueue.getInstance();
</code></pre>

<p>There are no errors, but </p>

<pre><code>System.out.println("Creating MessageQueue instance.");
</code></pre>

<p>is getting executed whenever I do </p>

<pre><code>MessageQueue messageQueue = MessageQueue.getInstance();
</code></pre>

<p><strong>EDIT 1</strong></p>

<pre><code>import java.util.LinkedList;

public class MessageQueue {

    private static final LinkedList&lt;ServerDataEvent&gt; queue = new LinkedList&lt;ServerDataEvent&gt;();;

    private static final MessageQueue messageQueue = new MessageQueue();

    /** A private Constructor prevents any other class from instantiating. */
    private MessageQueue() {
        System.out.println("problem...");
    }

    /** Static 'instance' method */
    public static MessageQueue getInstance() {
        return MessageQueue.messageQueue;
    }

    public Object clone() throws CloneNotSupportedException {
        throw new CloneNotSupportedException();
    }
}
</code></pre>
