Package Creational.Singleton
Class Singleton
java.lang.Object
Creational.Singleton.Singleton
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 Summary
Modifier and TypeMethodDescriptionvoidAn example method demonstrating Singleton functionality.static SingletonRetrieves the single instance of the Singleton class.
-
Method Details
-
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.
-