Class Singleton

java.lang.Object
Creational.Singleton.Singleton

public class Singleton extends Object
Implementation of the Singleton design pattern in Java. This class ensures that only one instance of the Singleton class exists throughout the application's lifetime.
  • Method Details

    • getInstance

      public static Singleton getInstance()
      Retrieves the single instance of the Singleton class. This method uses synchronized lazy initialization to ensure thread safety while creating the Singleton instance.
      Returns:
      The single instance of the Singleton class.
    • doSomething

      public void doSomething()
      An example method demonstrating Singleton functionality. This method performs an example action to showcase how to use the Singleton instance.