We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2fe4681 commit 11d23bfCopy full SHA for 11d23bf
1 file changed
src/main/java/cn/byhieg/designpatterntutorial/singleton/SimpleSingleton.java
@@ -0,0 +1,22 @@
1
+package cn.byhieg.designpatterntutorial.singleton;
2
+
3
+/**
4
+ * 该类线程不安全,是延迟加载的懒汉模式
5
+ * Created by shiqifeng on 2017/3/14.
6
+ * Mail byhieg@gmail.com
7
+ */
8
+public class SimpleSingleton {
9
10
+ private static SimpleSingleton simpleSingleton;
11
12
+ private SimpleSingleton(){
13
14
+ }
15
16
+ public static SimpleSingleton getInstance(){
17
+ if (simpleSingleton == null) {
18
+ simpleSingleton = new SimpleSingleton();
19
20
+ return simpleSingleton;
21
22
+}
0 commit comments