About 108,000 results
Open links in new tab
  1. What is an efficient way to implement a singleton pattern in Java ...

    Sep 16, 2008 · Narrowing the question will help others answer the question concisely. You may edit the question if you feel you can improve it yourself. If edited, the question will be reviewed and might be …

  2. On design patterns: When should I use the singleton?

    The glorified global variable - becomes a gloried global class. Some say breaking object-oriented design. Give me scenarios, other than the good old logger where it makes sense to use the singleton.

  3. Singleton & Multithreading in Java - Stack Overflow

    Jun 17, 2012 · The basic difference is that with the wrapper class version, the singleton instance is created when the wrapper class is loaded, which when the first call the getInstance() is made, but …

  4. Implementing Singleton with an Enum (in Java) - Stack Overflow

    Oct 10, 2014 · In this Java best practices book by Joshua Bloch, you can find explained why you should enforce the Singleton property with a private constructor or an Enum type.

  5. What are drawbacks or disadvantages of singleton pattern?

    The singleton pattern is a fully paid up member of the GoF 's patterns book, but it lately seems rather orphaned by the developer world. I still use quite a lot of singletons, especially for factory classes, …

  6. Implementing the singleton pattern in Java - Stack Overflow

    Jan 5, 2010 · Final note, the Double Checked Locking Pattern is broken in Java up to Java 5. The Java 5 memory model makes the DCL pattern thread safe but it makes it slower than the SingletonHolder …

  7. java - Where exactly the Singleton Pattern is used in real application ...

    Jul 7, 2010 · Singleton Pattern can be used for loading the configuration , say in a web application, we are supposed to generate a file which is to be stored somewhere in the server.

  8. Other Ways of Singleton in Java [duplicate] - Stack Overflow

    Jul 7, 2017 · Just i was thinking about the other ways of writing singleton class. So is this class considered as a singleton class? public class MyClass{ static Myclass myclass; ...

  9. java - Why use a singleton instead of static methods? - Stack Overflow

    May 24, 2021 · Another way to package singleton’s functionality is to use class operations (that is, static member functions in C++ or class methods in Smalltalk). But both of these language techniques …

  10. Java Singleton Design Pattern : Questions - Stack Overflow

    Feb 5, 2017 · Singleton is a creational pattern and hence governs object instantiation. Creating singletons would mandate that you voluntarily or involuntarily give up control on creating the object …