2021-11-08 18:25:28 +00:00
|
|
|
package z;
|
2021-06-27 20:44:35 +00:00
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.concurrent.Executor;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
2022-03-02 20:59:20 +00:00
|
|
|
/* compiled from: BoltsExecutors.java */
|
|
|
|
/* loaded from: classes.dex */
|
2021-06-27 20:44:35 +00:00
|
|
|
public final class b {
|
|
|
|
public static final b a = new b();
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
2022-03-22 15:40:06 +00:00
|
|
|
public final ExecutorService f3836b;
|
2021-12-21 23:37:30 +00:00
|
|
|
public final Executor c;
|
2021-06-27 20:44:35 +00:00
|
|
|
|
2022-03-02 20:59:20 +00:00
|
|
|
/* compiled from: BoltsExecutors.java */
|
2021-11-08 18:25:28 +00:00
|
|
|
/* renamed from: z.b$b reason: collision with other inner class name */
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes.dex */
|
|
|
|
public static class ExecutorC0437b implements Executor {
|
2021-12-17 22:03:14 +00:00
|
|
|
public ThreadLocal<Integer> j = new ThreadLocal<>();
|
2021-06-27 20:44:35 +00:00
|
|
|
|
2022-03-02 20:59:20 +00:00
|
|
|
public ExecutorC0437b(a aVar) {
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final int a() {
|
2021-12-17 22:03:14 +00:00
|
|
|
Integer num = this.j.get();
|
2021-06-27 20:44:35 +00:00
|
|
|
if (num == null) {
|
|
|
|
num = 0;
|
|
|
|
}
|
|
|
|
int intValue = num.intValue() - 1;
|
|
|
|
if (intValue == 0) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.j.remove();
|
2021-06-27 20:44:35 +00:00
|
|
|
} else {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.j.set(Integer.valueOf(intValue));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
return intValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.util.concurrent.Executor
|
|
|
|
public void execute(Runnable runnable) {
|
2021-12-17 22:03:14 +00:00
|
|
|
Integer num = this.j.get();
|
2021-06-27 20:44:35 +00:00
|
|
|
if (num == null) {
|
|
|
|
num = 0;
|
|
|
|
}
|
|
|
|
int intValue = num.intValue() + 1;
|
2021-12-17 22:03:14 +00:00
|
|
|
this.j.set(Integer.valueOf(intValue));
|
2022-03-02 20:59:20 +00:00
|
|
|
try {
|
|
|
|
if (intValue <= 15) {
|
2021-06-27 20:44:35 +00:00
|
|
|
runnable.run();
|
2022-03-02 20:59:20 +00:00
|
|
|
} else {
|
2022-03-22 15:40:06 +00:00
|
|
|
b.a.f3836b.execute(runnable);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2022-03-02 20:59:20 +00:00
|
|
|
} finally {
|
|
|
|
a();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public b() {
|
|
|
|
ThreadPoolExecutor threadPoolExecutor;
|
|
|
|
String property = System.getProperty("java.runtime.name");
|
|
|
|
if (!(property == null ? false : property.toLowerCase(Locale.US).contains("android"))) {
|
|
|
|
threadPoolExecutor = Executors.newCachedThreadPool();
|
|
|
|
} else {
|
|
|
|
a aVar = a.a;
|
2022-03-02 20:59:20 +00:00
|
|
|
ThreadPoolExecutor threadPoolExecutor2 = new ThreadPoolExecutor(a.c, a.d, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue());
|
2021-06-27 20:44:35 +00:00
|
|
|
threadPoolExecutor2.allowCoreThreadTimeOut(true);
|
|
|
|
threadPoolExecutor = threadPoolExecutor2;
|
|
|
|
}
|
2022-03-22 15:40:06 +00:00
|
|
|
this.f3836b = threadPoolExecutor;
|
2021-06-27 20:44:35 +00:00
|
|
|
Executors.newSingleThreadScheduledExecutor();
|
2022-03-02 20:59:20 +00:00
|
|
|
this.c = new ExecutorC0437b(null);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|