53 lines
1.6 KiB
Java
53 lines
1.6 KiB
Java
package com.ubt.jimu.utils;
|
|
|
|
import java.util.Iterator;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class ThreadManagerUtils {
|
|
private static final ThreadPoolProxy a = new ThreadPoolProxy(1, 3, 5000);
|
|
|
|
public static ThreadPoolProxy a() {
|
|
return a;
|
|
}
|
|
|
|
public static class ThreadPoolProxy {
|
|
private final int a;
|
|
private final int b;
|
|
private final long c;
|
|
private ThreadPoolExecutor d;
|
|
|
|
public ThreadPoolProxy(int i, int i2, long j) {
|
|
this.a = i;
|
|
this.b = i2;
|
|
this.c = j;
|
|
}
|
|
|
|
private void b() {
|
|
ThreadPoolExecutor threadPoolExecutor = this.d;
|
|
if (threadPoolExecutor == null || threadPoolExecutor.isShutdown()) {
|
|
this.d = new ThreadPoolExecutor(this.a, this.b, this.c, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardPolicy());
|
|
}
|
|
}
|
|
|
|
public void a(Runnable runnable) {
|
|
b();
|
|
this.d.execute(runnable);
|
|
}
|
|
|
|
public void a() {
|
|
ThreadPoolExecutor threadPoolExecutor = this.d;
|
|
if (threadPoolExecutor == null || threadPoolExecutor.isShutdown()) {
|
|
return;
|
|
}
|
|
Iterator it = this.d.getQueue().iterator();
|
|
while (it.hasNext()) {
|
|
this.d.remove((Runnable) it.next());
|
|
}
|
|
}
|
|
}
|
|
}
|