61 lines
2.5 KiB
Java
61 lines
2.5 KiB
Java
package com.alibaba.android.arouter.thread;
|
|
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
import com.alibaba.android.arouter.utils.TextUtils;
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
import java.util.concurrent.BlockingQueue;
|
|
import java.util.concurrent.CancellationException;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.Future;
|
|
import java.util.concurrent.RejectedExecutionHandler;
|
|
import java.util.concurrent.ThreadFactory;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DefaultPoolExecutor extends ThreadPoolExecutor {
|
|
private static final int a = Runtime.getRuntime().availableProcessors();
|
|
private static final int b = a + 1;
|
|
private static final int c = b;
|
|
private static DefaultPoolExecutor d;
|
|
|
|
private DefaultPoolExecutor(int i, int i2, long j, TimeUnit timeUnit, BlockingQueue<Runnable> blockingQueue, ThreadFactory threadFactory) {
|
|
super(i, i2, j, timeUnit, blockingQueue, threadFactory, new RejectedExecutionHandler() { // from class: com.alibaba.android.arouter.thread.DefaultPoolExecutor.1
|
|
@Override // java.util.concurrent.RejectedExecutionHandler
|
|
public void rejectedExecution(Runnable runnable, ThreadPoolExecutor threadPoolExecutor) {
|
|
ARouter.c.b("ARouter::", "Task rejected, too many task!");
|
|
}
|
|
});
|
|
}
|
|
|
|
public static DefaultPoolExecutor a() {
|
|
if (d == null) {
|
|
synchronized (DefaultPoolExecutor.class) {
|
|
if (d == null) {
|
|
d = new DefaultPoolExecutor(b, c, 30L, TimeUnit.SECONDS, new ArrayBlockingQueue(64), new DefaultThreadFactory());
|
|
}
|
|
}
|
|
}
|
|
return d;
|
|
}
|
|
|
|
@Override // java.util.concurrent.ThreadPoolExecutor
|
|
protected void afterExecute(Runnable runnable, Throwable th) {
|
|
super.afterExecute(runnable, th);
|
|
if (th == null && (runnable instanceof Future)) {
|
|
try {
|
|
((Future) runnable).get();
|
|
} catch (InterruptedException unused) {
|
|
Thread.currentThread().interrupt();
|
|
} catch (CancellationException e) {
|
|
th = e;
|
|
} catch (ExecutionException e2) {
|
|
th = e2.getCause();
|
|
}
|
|
}
|
|
if (th != null) {
|
|
ARouter.c.c("ARouter::", "Running task appeared exception! Thread [" + Thread.currentThread().getName() + "], because [" + th.getMessage() + "]\n" + TextUtils.a(th.getStackTrace()));
|
|
}
|
|
}
|
|
}
|