diff --git "a/\347\234\237\347\276\241\346\205\225\344\275\240\344\273\254\346\234\211\351\202\243\344\271\210\345\244\232\345\257\271\350\261\241\357\274\214\357\274\214\357\274\214\345\217\257\344\273\245\350\242\253GC.java" "b/\347\234\237\347\276\241\346\205\225\344\275\240\344\273\254\346\234\211\351\202\243\344\271\210\345\244\232\345\257\271\350\261\241\357\274\214\357\274\214\357\274\214\345\217\257\344\273\245\350\242\253GC.java" new file mode 100644 index 0000000000000000000000000000000000000000..05d2bd0298d6879c8e506f10c98b92908aa8d1e9 --- /dev/null +++ "b/\347\234\237\347\276\241\346\205\225\344\275\240\344\273\254\346\234\211\351\202\243\344\271\210\345\244\232\345\257\271\350\261\241\357\274\214\357\274\214\357\274\214\345\217\257\344\273\245\350\242\253GC.java" @@ -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 you 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