Created
May 18, 2020 21:33
-
-
Save vepo/7d25219a34f3d9376cb7cd136826283e to your computer and use it in GitHub Desktop.
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 SomeSingleton { | |
private static final instance AtomicReference<SomeSingleton> ref = new AtomicReference<>(); | |
public static SomeSingleton get() { | |
return instance.updateAndGet(e -> { | |
return isNull(e) ? new SomeSingleton() : e; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment