We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 11d23bf commit b11ae91Copy full SHA for b11ae91
1 file changed
src/main/java/cn/byhieg/designpatterntutorial/singleton/DCLSingleton.java
@@ -0,0 +1,26 @@
1
+package cn.byhieg.designpatterntutorial.singleton;
2
+
3
+/**
4
+ * Created by shiqifeng on 2017/3/14.
5
+ * Mail byhieg@gmail.com
6
+ */
7
+public class DCLSingleton {
8
9
+ private static volatile DCLSingleton singleton;
10
11
+ private DCLSingleton(){
12
13
+ }
14
15
+ public static DCLSingleton getSingleton(){
16
+ if (singleton == null) {
17
+ synchronized (DCLSingleton.class) {
18
19
+ singleton = new DCLSingleton();
20
21
22
23
+ return singleton;
24
25
26
+}
0 commit comments