补充提交 体温检测用到的ThreadPool
authorsnickersun <scy@incartech.cn>
Mon, 28 Dec 2020 13:22:22 +0000 (21:22 +0800)
committersnickersun <scy@incartech.cn>
Mon, 28 Dec 2020 13:22:22 +0000 (21:22 +0800)
app/src/main/java/com/enqualcomm/support/utils/ThreadPool.java [new file with mode: 0644]

diff --git a/app/src/main/java/com/enqualcomm/support/utils/ThreadPool.java b/app/src/main/java/com/enqualcomm/support/utils/ThreadPool.java
new file mode 100644 (file)
index 0000000..5879c7f
--- /dev/null
@@ -0,0 +1,35 @@
+package com.enqualcomm.support.utils;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+final public class ThreadPool {
+
+    private ExecutorService mService;
+
+    private volatile static ThreadPool instance;
+
+    public ThreadPool() {
+        mService = Executors.newCachedThreadPool();
+    }
+
+
+    public static ThreadPool newInstance() {
+        if (instance == null) {
+            synchronized (ThreadPool.class) {
+                if (instance == null) {
+                    instance = new ThreadPool();
+                }
+            }
+        }
+        return instance;
+    }
+
+    public Future<?> submitThreadPool(Runnable runnable) {
+        if (runnable == null) {
+            return null;
+        }
+        return mService.submit(runnable);
+    }
+}