Initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.alibaba.android.arouter.thread;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import java.lang.Thread;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DefaultThreadFactory implements ThreadFactory {
|
||||
private static final AtomicInteger d = new AtomicInteger(1);
|
||||
private final AtomicInteger a = new AtomicInteger(1);
|
||||
private final ThreadGroup b;
|
||||
private final String c;
|
||||
|
||||
public DefaultThreadFactory() {
|
||||
SecurityManager securityManager = System.getSecurityManager();
|
||||
this.b = securityManager != null ? securityManager.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
||||
this.c = "ARouter task pool No." + d.getAndIncrement() + ", thread No.";
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadFactory
|
||||
public Thread newThread(Runnable runnable) {
|
||||
String str = this.c + this.a.getAndIncrement();
|
||||
ARouter.c.d("ARouter::", "Thread production, name is [" + str + "]");
|
||||
Thread thread = new Thread(this.b, runnable, str, 0L);
|
||||
if (thread.isDaemon()) {
|
||||
thread.setDaemon(false);
|
||||
}
|
||||
if (thread.getPriority() != 5) {
|
||||
thread.setPriority(5);
|
||||
}
|
||||
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(this) { // from class: com.alibaba.android.arouter.thread.DefaultThreadFactory.1
|
||||
@Override // java.lang.Thread.UncaughtExceptionHandler
|
||||
public void uncaughtException(Thread thread2, Throwable th) {
|
||||
ARouter.c.d("ARouter::", "Running task appeared exception! Thread [" + thread2.getName() + "], because [" + th.getMessage() + "]");
|
||||
}
|
||||
});
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user