discord-jadx/app/src/main/java/z/b.java

78 lines
2.5 KiB
Java

package z;
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;
/* compiled from: BoltsExecutors.java */
/* loaded from: classes.dex */
public final class b {
public static final b a = new b();
/* renamed from: b reason: collision with root package name */
public final ExecutorService f3831b;
public final Executor c;
/* compiled from: BoltsExecutors.java */
/* renamed from: z.b$b reason: collision with other inner class name */
/* loaded from: classes.dex */
public static class ExecutorC0437b implements Executor {
public ThreadLocal<Integer> j = new ThreadLocal<>();
public ExecutorC0437b(a aVar) {
}
public final int a() {
Integer num = this.j.get();
if (num == null) {
num = 0;
}
int intValue = num.intValue() - 1;
if (intValue == 0) {
this.j.remove();
} else {
this.j.set(Integer.valueOf(intValue));
}
return intValue;
}
@Override // java.util.concurrent.Executor
public void execute(Runnable runnable) {
Integer num = this.j.get();
if (num == null) {
num = 0;
}
int intValue = num.intValue() + 1;
this.j.set(Integer.valueOf(intValue));
try {
if (intValue <= 15) {
runnable.run();
} else {
b.a.f3831b.execute(runnable);
}
} finally {
a();
}
}
}
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;
ThreadPoolExecutor threadPoolExecutor2 = new ThreadPoolExecutor(a.c, a.d, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue());
threadPoolExecutor2.allowCoreThreadTimeOut(true);
threadPoolExecutor = threadPoolExecutor2;
}
this.f3831b = threadPoolExecutor;
Executors.newSingleThreadScheduledExecutor();
this.c = new ExecutorC0437b(null);
}
}