48 lines
1.2 KiB
Java
48 lines
1.2 KiB
Java
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);
|
|
}
|
|
}
|