What is real life use of singletone class in java

Showing Answers 1 - 4 of 4 Answers

K.prabanand

  • May 15th, 2006
 

By using singleton class we can create only one object for a particlare class..........ie(only one copy will be created for all instance)

  Was this answer useful?  Yes

Kavitha

  • May 22nd, 2006
 

The best use is, In most of the pooling(Connection Pool) we use singleton to access the connection

  Was this answer useful?  Yes

rgoel79

  • May 25th, 2006
 

Singleton ensures that you have only one object of a particular class per JVM.

It is used when you need to refer to same object in say different instances of other classes. e.g. in a servlet, each time you need a resource, like connection, instead of creating a new object, you can centralise the calls to get connection to a single object. Advantages? Helps you pool the connection, hence everytime you need an expensive resource, you dont recreate it.

Per JVM is important to understand. It means that if you do load balancing, where you have same application running on different servers, there will be one singleton for each server. Hence, its one instance per JVm which is guarented.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions