94 lines
2.7 KiB
Java
94 lines
2.7 KiB
Java
|
package com.huawei.hms.hatool;
|
||
|
|
||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||
|
import java.util.concurrent.RejectedExecutionException;
|
||
|
import java.util.concurrent.ThreadFactory;
|
||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class b0 {
|
||
|
private static b0 b;
|
||
|
private static b0 c;
|
||
|
private static b0 d;
|
||
|
private ThreadPoolExecutor a = new ThreadPoolExecutor(0, 1, 60000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(5000), new b());
|
||
|
|
||
|
public void a(g gVar) {
|
||
|
try {
|
||
|
this.a.execute(new a(gVar));
|
||
|
} catch (RejectedExecutionException unused) {
|
||
|
v.e("hmsSdk", "addToQueue() Exception has happened!Form rejected execution");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static b0 c() {
|
||
|
return b;
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class b implements ThreadFactory {
|
||
|
private static final AtomicInteger d = new AtomicInteger(1);
|
||
|
private final ThreadGroup a;
|
||
|
private final AtomicInteger b = new AtomicInteger(1);
|
||
|
private final String c;
|
||
|
|
||
|
@Override // java.util.concurrent.ThreadFactory
|
||
|
public Thread newThread(Runnable runnable) {
|
||
|
ThreadGroup threadGroup = this.a;
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(this.c);
|
||
|
sb.append(this.b.getAndIncrement());
|
||
|
return new Thread(threadGroup, runnable, sb.toString(), 0L);
|
||
|
}
|
||
|
|
||
|
b() {
|
||
|
SecurityManager securityManager = System.getSecurityManager();
|
||
|
this.a = securityManager != null ? securityManager.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
||
|
StringBuilder sb = new StringBuilder("FormalHASDK-base-");
|
||
|
sb.append(d.getAndIncrement());
|
||
|
this.c = sb.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static b0 b() {
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class a implements Runnable {
|
||
|
private Runnable a;
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public void run() {
|
||
|
Runnable runnable = this.a;
|
||
|
if (runnable != null) {
|
||
|
try {
|
||
|
runnable.run();
|
||
|
} catch (Exception unused) {
|
||
|
v.e("hmsSdk", "InnerTask : Exception has happened,From internal operations!");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public a(Runnable runnable) {
|
||
|
this.a = runnable;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static b0 a() {
|
||
|
return d;
|
||
|
}
|
||
|
|
||
|
private b0() {
|
||
|
}
|
||
|
|
||
|
static {
|
||
|
new b0();
|
||
|
new b0();
|
||
|
b = new b0();
|
||
|
c = new b0();
|
||
|
d = new b0();
|
||
|
}
|
||
|
}
|