Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Implementing a Serializable Singleton 
 

In Singeton classes only one instance will be created.

 

Implementing a Serializable Singleton

                         

In Singeton classes only one instance will be created. We are going to serialize the class. This can be done very easily. What we need to do is to implement a java.io.Serializable interface. We will use a method of Serializable interface that is readResolve().

readResolve(): It returns Object and throw ObjectStreamException

 

Code of the program is given below:

 

 

import java.io.*;

public class SerializableSingleton implements java.io.Serializable {
  
   static SerializableSingleton singleton;
   protected SerializableSingleton() 
  {
      // Exists only to thwart instantiation.
    }
      private Object readResolve() 
  {
           return instancd;
  }
  public static void main(String args[])
    {
      singleton = new SerializableSingleton();
      singleton.readResolve();
    }
}

Download this program

                         

» View all related tutorials
Related Tags: c file class orm constructor object path struct const value name return instance paths create if send match to bot

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

Optional single application instance enforcement and multiple startup notification
My application must only be started once. Existing application windows will be brought to the top if a user starts the application a second time.how is it possible with your excelsior, what type of navigations must be considerd in applying the above mentioned query.

Posted by Aparna on Tuesday, 01.23.07 @ 12:28pm | #4131

Thanks for this wonderful program as it
has helped me a lot.

Posted by Ashutosh pandey on Sunday, 12.24.06 @ 12:01pm | #1540

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.