Created
August 25, 2025 10:58
-
-
Save jeffque/eaea816ded80409951e833c4d88f9d13 to your computer and use it in GitHub Desktop.
Singleton, leveraging to classloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MustBeSingleton { | |
| private MustBeSingleton() { | |
| } | |
| public static MustBeSingleton getInstance() { | |
| return SINGLETON_LOADER.singleton; | |
| } | |
| private static class SINGLETON_LOADER { | |
| static final MustBeSingleton singleton = new MustBeSingleton(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment