package w; import android.os.Handler; import android.os.Process; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /* loaded from: classes.dex */ abstract class g { private static class a implements ThreadFactory { /* renamed from: a, reason: collision with root package name */ private String f14982a; /* renamed from: b, reason: collision with root package name */ private int f14983b; /* renamed from: w.g$a$a, reason: collision with other inner class name */ private static class C0251a extends Thread { /* renamed from: a, reason: collision with root package name */ private final int f14984a; C0251a(Runnable runnable, String str, int i10) { super(runnable, str); this.f14984a = i10; } @Override // java.lang.Thread, java.lang.Runnable public void run() { Process.setThreadPriority(this.f14984a); super.run(); } } a(String str, int i10) { this.f14982a = str; this.f14983b = i10; } @Override // java.util.concurrent.ThreadFactory public Thread newThread(Runnable runnable) { return new C0251a(runnable, this.f14982a, this.f14983b); } } private static class b implements Runnable { /* renamed from: a, reason: collision with root package name */ private Callable f14985a; /* renamed from: b, reason: collision with root package name */ private y.a f14986b; /* renamed from: c, reason: collision with root package name */ private Handler f14987c; class a implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ y.a f14988a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ Object f14989b; a(y.a aVar, Object obj) { this.f14988a = aVar; this.f14989b = obj; } @Override // java.lang.Runnable public void run() { this.f14988a.a(this.f14989b); } } b(Handler handler, Callable callable, y.a aVar) { this.f14985a = callable; this.f14986b = aVar; this.f14987c = handler; } @Override // java.lang.Runnable public void run() { Object obj; try { obj = this.f14985a.call(); } catch (Exception unused) { obj = null; } this.f14987c.post(new a(this.f14986b, obj)); } } static ThreadPoolExecutor a(String str, int i10, int i11) { ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, i11, TimeUnit.MILLISECONDS, new LinkedBlockingDeque(), new a(str, i10)); threadPoolExecutor.allowCoreThreadTimeOut(true); return threadPoolExecutor; } static void b(Executor executor, Callable callable, y.a aVar) { executor.execute(new b(w.b.a(), callable, aVar)); } static Object c(ExecutorService executorService, Callable callable, int i10) { try { return executorService.submit(callable).get(i10, TimeUnit.MILLISECONDS); } catch (InterruptedException e10) { throw e10; } catch (ExecutionException e11) { throw new RuntimeException(e11); } catch (TimeoutException unused) { throw new InterruptedException("timeout"); } } }