From 5ce1bfc7566ded2c11a6283e6c65eeb7b06cf565 Mon Sep 17 00:00:00 2001 From: cyb393 <44234950+cyb393@users.noreply.github.com> Date: Thu, 8 Nov 2018 12:44:35 +0800 Subject: [PATCH] Update Test02.java --- src/Test02.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Test02.java b/src/Test02.java index 6034b11..7aac381 100644 --- a/src/Test02.java +++ b/src/Test02.java @@ -1,5 +1,5 @@ /** - * Author: + * Author: 王俊超 * Date: 2015-04-21 * Time: 13:58 * Declaration: All Rights Reserved !!! @@ -7,7 +7,7 @@ public class Test02 { /** - * ģʽʽ̰߳ȫ + * 单例模式,饿汉式,线程安全 */ public static class Singleton { private final static Singleton INSTANCE = new Singleton(); @@ -22,7 +22,7 @@ public static Singleton getInstance() { } /** - * ģʽʽ̲߳ȫ + * 单例模式,懒汉式,线程不安全 */ public static class Singleton2 { private static Singleton2 instance = null; @@ -42,7 +42,7 @@ public static Singleton2 getInstance() { /** - * ģʽʽ̰߳ȫ̻߳Чʲ + * 单例模式,懒汉式,线程安全,多线程环境下效率不高 */ public static class Singleton3 { private static Singleton3 instance = null; @@ -61,7 +61,7 @@ public static synchronized Singleton3 getInstance() { } /** - * ģʽʽ֣̰߳ȫ + * 单例模式,懒汉式,变种,线程安全 */ public static class Singleton4 { private static Singleton4 instance = null; @@ -80,7 +80,7 @@ public static Singleton4 getInstance() { } /** - * ģʽʽʹþ̬ڲ̰࣬߳ȫƼ + * 单例模式,饿汉式,使用静态内部类,线程安全【推荐】 */ public static class Singleton5 { private final static class SingletonHolder { @@ -97,7 +97,7 @@ public static Singleton5 getInstance() { } /** - * ̬ڲ࣬ʹöٷʽ̰߳ȫƼ + * 静态内部类,使用枚举方式,线程安全【推荐】 */ public enum Singleton6 { INSTANCE; @@ -108,7 +108,7 @@ public void whateverMethod() { } /** - * ̬ڲ࣬ʹ˫У̰߳ȫƼ + * 静态内部类,使用双重校验锁,线程安全【推荐】 */ public static class Singleton7 { private volatile static Singleton7 instance = null;