Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 709 Bytes

README.md

File metadata and controls

15 lines (12 loc) · 709 Bytes

all-about-singletons

This repository demonstrates all main patterns which can be used to create singletons in Java. A more detailed explanation can be found at http://blog.dulaj.info/2017/07/java-singletons-using-enum-type-best.html.

Singleton patterns implemented

  • Singleton with public static final field
  • Singleton with static factory method
  • Singleton with lazy initialization and fine grained synchronization
  • Singleton with enum

Problems with singletons demostrated here

  • Serialize and Deserialize problem
  • Problem with private constructor when using reflection

License

All the source code has been licensed under MIT License and free to use for any kind of work.