discord-jadx/app/src/main/java/z/b.java
2021-11-29 22:56:34 +01:00

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