File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes About Using  Singleton class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "About Using  Singleton class " Watch "About Using  Singleton class " New topic
Author

About Using Singleton class

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi all ,

Can anybody please tell me where exactly a Singleton Class would be useful in a Web Based Appliction ??


I know this :

"Singletons are truly useful when you need only one instance of a class, and it is undesirable to have more than one instance of a class."

But where actually this is a case ?
please tell me an example .

Thanks in advance .


Save India From Corruption - Anna Hazare.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

When I google for "use of singleton" I get a *lot* of hits--which ones have you looked at so far and/or what about them didn't you understand?
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi David ,
Thanks for the response
When it is required for a single point of entry in a Application ??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not sure I know what you're asking; sorry!
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234




Hi , i want to know in what situation ,In fact we should restrict the maximum number of object of a class.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Ravi Pavan wrote:
i want to know in what situation ,In fact we should restrict the maximum number of object of a class.

That's an impossible question--there could be any number of reasons why we'd want to restrict the number of class instantiations. The most common would be because we only need one instance. Singletons are, however, frequently debated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About Using Singleton class
 
Similar Threads
Doubt with a singleton class
Singleton class
ClassLoaders
singleton synchronized doubt
Synchronization for Singleton