DeserSingle

public class MySingleton implements Serializable {
    static MySingleton singleton = new MySingleton();

    private MySingleton() {
    }

    // This method is called immediately after an object of this class is deserialized.
    // This method returns the singleton instance.
    protected Object readResolve() {
        return singleton;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.