diff --git "a/\343\200\202java" "b/\343\200\202java" new file mode 100644 index 0000000000000000000000000000000000000000..6166072f79fdf1ff3df88649e711ed1e9cbcb05e --- /dev/null +++ "b/\343\200\202java" @@ -0,0 +1,33 @@ +/** + * @className: GirlFriendSingleton + * @description: Love a person and live to death + **/ +@Slf4j +public class GirlFriendSingleton { + + // Often miss you through time and space + volatile private static GirlFriendSingleton girlFriend = null; + + private GirlFriendSingleton(){ + } + + public static GirlFriendSingleton getInstance() { + try { + // My love, Where are you + if(null == girlFriend){ + Thread.sleep(300); + // Everything i want is yours + synchronized (GirlFriendSingleton.class) { + // Only U, and it must be U + if(null == girlFriend){ + girlFriend = new GirlFriendSingleton(); + } + } + } + } catch (InterruptedException e) { + // Love a person and live to death + log.error(e.getMessage()); + } + return girlFriend; + } +} \ No newline at end of file