Skip to content

Instantly share code, notes, and snippets.

@vepo
Created May 18, 2020 21:33
Show Gist options
  • Save vepo/7d25219a34f3d9376cb7cd136826283e to your computer and use it in GitHub Desktop.
Save vepo/7d25219a34f3d9376cb7cd136826283e to your computer and use it in GitHub Desktop.
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