a.java 源代码
package x0;
import android.os.Process;
import android.util.Log;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class a extends ThreadPoolExecutor {
private final AtomicInteger f27500q;
private final d f27501r;
public static class b implements ThreadFactory {
int f27502a = 0;
class C0362a extends Thread {
C0362a(Runnable runnable, String str) {
super(runnable, str);
}
@Override
public void run() {
Process.setThreadPriority(10);
super.run();
}
}
@Override
public Thread newThread(Runnable runnable) {
C0362a c0362a = new C0362a(runnable, "fifo-pool-thread-" + this.f27502a);
this.f27502a = this.f27502a + 1;
return c0362a;
}
}
static class c<T> extends FutureTask<T> implements Comparable<c<?>> {
private final int f27504q;
private final int f27505r;
public c(Runnable runnable, T t6, int i6) {
super(runnable, t6);
if (runnable instanceof x0.b) {
this.f27504q = ((x0.b) runnable).a();
this.f27505r = i6;
return;
}
throw new IllegalArgumentException("FifoPriorityThreadPoolExecutor must be given Runnables that implement Prioritized");
}
@Override
public int compareTo(c<?> cVar) {
int i6 = this.f27504q - cVar.f27504q;
if (i6 == 0) {
return this.f27505r - cVar.f27505r;
}
return i6;
}
public boolean equals(Object obj) {
if (!(obj instanceof c)) {
return false;
}
c cVar = (c) obj;
if (this.f27505r != cVar.f27505r || this.f27504q != cVar.f27504q) {
return false;
}
return true;
}
public int hashCode() {
return (this.f27504q * 31) + this.f27505r;
}
}
public static class d {
public static final d f27506q;
public static final d f27507r;
public static final d f27508s;
private static final d[] f27509t;
enum C0363a extends d {
C0363a(String str, int i6) {
super(str, i6);
}
@Override
protected void a(Throwable th) {
if (Log.isLoggable("PriorityExecutor", 6)) {
Log.e("PriorityExecutor", "Request threw uncaught throwable", th);
}
}
}
enum b extends d {
b(String str, int i6) {
super(str, i6);
}
@Override
protected void a(Throwable th) {
super.a(th);
throw new RuntimeException(th);
}
}
static {
d dVar = new d("IGNORE", 0);
f27506q = dVar;
C0363a c0363a = new C0363a("LOG", 1);
f27507r = c0363a;
b bVar = new b("THROW", 2);
f27508s = bVar;
f27509t = new d[]{dVar, c0363a, bVar};
}
private d(String str, int i6) {
}
public static d valueOf(String str) {
return (d) Enum.valueOf(d.class, str);
}
public static d[] values() {
return (d[]) f27509t.clone();
}
protected void a(Throwable th) {
}
}
public a(int i6) {
this(i6, d.f27507r);
}
@Override
protected void afterExecute(Runnable runnable, Throwable th) {
super.afterExecute(runnable, th);
if (th == null && (runnable instanceof Future)) {
Future future = (Future) runnable;
if (future.isDone() && !future.isCancelled()) {
try {
future.get();
} catch (InterruptedException e6) {
this.f27501r.a(e6);
} catch (ExecutionException e7) {
this.f27501r.a(e7);
}
}
}
}
@Override
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T t6) {
return new c(runnable, t6, this.f27500q.getAndIncrement());
}
public a(int i6, d dVar) {
this(i6, i6, 0L, TimeUnit.MILLISECONDS, new b(), dVar);
}
public a(int i6, int i7, long j6, TimeUnit timeUnit, ThreadFactory threadFactory, d dVar) {
super(i6, i7, j6, timeUnit, new PriorityBlockingQueue(), threadFactory);
this.f27500q = new AtomicInteger();
this.f27501r = dVar;
}
}