Initial commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.afunx.ble.blelitelib.threadpool;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BleThreadpool {
|
||||
private static BleThreadpool instance = new BleThreadpool();
|
||||
private Handler mMainHandler = new Handler(Looper.getMainLooper());
|
||||
private ExecutorService mExecutor = Executors.newCachedThreadPool();
|
||||
|
||||
private BleThreadpool() {
|
||||
}
|
||||
|
||||
public static BleThreadpool getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
this.mExecutor.shutdown();
|
||||
}
|
||||
|
||||
public List<Runnable> shutdownNow() {
|
||||
return this.mExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
public <T> Future<T> submit(Callable<T> callable) {
|
||||
return this.mExecutor.submit(callable);
|
||||
}
|
||||
|
||||
public void submitInMain(Runnable runnable) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
runnable.run();
|
||||
} else {
|
||||
this.mMainHandler.post(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
public Future<?> submit(Runnable runnable) {
|
||||
return this.mExecutor.submit(runnable);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user