We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bae6530 commit 7917d5cCopy full SHA for 7917d5c
src/cn/trinea/android/common/util/SingletonUtils.java
@@ -0,0 +1,25 @@
1
+package cn.trinea.android.common.util;
2
+
3
+/**
4
+ * Singleton helper class for lazily initialization.
5
+ *
6
+ * @author <a href="http://www.trinea.cn/" target="_blank">Trinea</a>
7
8
+ * @param <T>
9
+ */
10
+public abstract class SingletonUtils<T> {
11
+ private T instance;
12
13
+ protected abstract T newInstance();
14
15
+ public final T getInstance() {
16
+ if (instance == null) {
17
+ synchronized (SingletonUtils.class) {
18
19
+ instance = newInstance();
20
+ }
21
22
23
+ return instance;
24
25
+}
0 commit comments