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

    Sep 16, 2008 · It doesn't enforce the "singleton-ness" of the class (which you can't really do anyway if there are multiple class loaders involved), but it provides a really easy way to build …

  2. java - How to create a singleton class - Stack Overflow

    What is the best/correct way to create a singleton class in java? One of the implementation I found is using a private constructor and a getInstance() method. package singleton; public …

  3. Different ways to write singleton in Java - Stack Overflow

    Dec 10, 2009 · The classic of writing a singleton in java is like this: public class SingletonObject { private SingletonObject() { } public static SingletonObject getSingletonObject() { ...

  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. The chapter …

  5. Singleton & Multithreading in Java - Stack Overflow

    Jun 17, 2012 · What is the preferred way to work with Singleton class in multithreaded environment? Suppose if I have 3 threads, and all of them try to access getInstance() method …

  6. oop - Singleton with Arguments in Java - Stack Overflow

    We build singleton class to create a single instance of an object in one application run. By having a constructor with parameter, you can build flexibility into your code to change some attributes …

  7. Java Singleton and Synchronization - Stack Overflow

    Jun 23, 2012 · Please clarify my queries regarding Singleton and Multithreading: What is the best way to implement Singleton in Java, in a multithreaded environment? What happens when …

  8. 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 …

  9. Implementing the singleton pattern in Java - Stack Overflow

    Jan 5, 2010 · Basically, in Java you implement singleton by giving a class a private no-args constructor (private MyClass()), and statically (or lazily) initializing a single instance of the …

  10. java - Why use a singleton instead of static methods? - Stack …

    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 make …