-1

The singleton mechanism helps us to create an instance which is static in nature. But when using it in a network environment ie; when more than one client is using the application, does this makes the system slower by blocking the creation of new instances.

Dileep
  • 5,362
  • 3
  • 22
  • 38
  • can anyone tell me why i got this negative marking on this question so that i can correct next time. – Dileep Feb 28 '13 at 05:23
  • It's nominated for closure as 'primarily opinion based', which it is: what slows down a system is a function of many things, not just whether some instance of some object is a singleton. Whether in your case it's a problem is undiagnosable with the provided information - and thus answers will merely be opinions. Note that by the nature of a singleton, having one will not 'block' other code pathways from using it. All pathways in the same execution environment will merely be referencing the same underlying bytecode. – Nathaniel Ford Nov 08 '13 at 19:12

1 Answers1

1

does this makes the system slower by blocking the creation of new instances.

I don't think so. Singleton only allows one instance per application domain. So if the new instance is not created, existing instance will be returned. (Other thing that should be taken into consideration with respect to singleton would be thread safety.)

Habib
  • 219,104
  • 29
  • 407
  • 436
  • thanks for your reply. I would like to know more about singleton can you suggest me any tutorials..?? – Dileep Feb 26 '13 at 06:16
  • 1
    @Dileep, See: http://www.ibm.com/developerworks/java/library/j-dcl/index.html and You may see also this question for [Singleton Anti Pattern](http://stackoverflow.com/questions/1448393/singleton-design-pattern-pitfalls) and – Habib Feb 26 '13 at 06:18