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

    Sep 16, 2008 · "This approach is functionally equivalent to the public field approach, except that it is more concise, provides the serialization machinery for free, and provides an ironclad …

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

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

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

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

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

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

  8. 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() { ...

  9. why are there java singleton classes? When would you need to use …

    Apr 30, 2011 · A singleton has the advantatage over a class with static variables and methods : it's an object instance, which can inherit from a class (example : an application that ahas a …

  10. Multiple instances of Singleton class. Possible?

    Nov 27, 2014 · 4 Can singleton class have multiple instances? Ans: NO This is the simple example for Singleton class in java. By calling Singleton.getInstance() you can get the …