Created
December 14, 2017 02:38
-
-
Save javarouka/26c112bc30bfb537cea691ef1f3c73cf to your computer and use it in GitHub Desktop.
Singleton - Layholder
This file contains 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
package io.javarouka.gist.pattern; | |
import lombok.extern.slf4j.Slf4j; | |
@Slf4j | |
public class SingletonLayholder { | |
static { | |
log.debug("SingletonLayholder initialized"); | |
} | |
private SingletonLayholder() { | |
log.debug("Created! " + this.getClass().getSimpleName()); | |
} | |
public static void foke() { | |
log.debug("fork!"); | |
} | |
public static SingletonLayholder getInstance() { | |
return LazyHolder.INSTANCE; | |
} | |
private static class LazyHolder { | |
static { | |
log.debug("SingletonLayholder.LazyHolder initialized"); | |
} | |
private static final SingletonTestLayholder INSTANCE = new SingletonTestLayholder(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment