package com.mbridge.msdk.foundation.same.e; import com.mbridge.msdk.MBridgeConstans; import com.mbridge.msdk.foundation.tools.af; import com.mbridge.msdk.foundation.tools.ah; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /* loaded from: classes4.dex */ public final class c { private static volatile ThreadPoolExecutor a; private static int a(int i, String str) { try { int a2 = ah.a().a(str, i); return a2 <= 0 ? i : a2; } catch (Exception e) { if (!MBridgeConstans.DEBUG) { return i; } af.b("CommonTaskLoaderThreadPool", e.getMessage()); return i; } } public static ThreadPoolExecutor a() { if (a == null) { int a2 = a(10, "c_t_l_t_p_c"); int a3 = a(50, "c_t_l_t_p_m"); int a4 = a(5, "c_t_l_t_p_t"); int i = a3 < a2 ? a2 : a3; try { if (MBridgeConstans.DEBUG) { af.a("CommonTaskLoaderThreadPool", "create ThreadPoolExecutor for core " + a2 + " max " + i + " timeout " + a4); } long j = a4; if (j <= 0) { j = 1; } a = new ThreadPoolExecutor(a2, i, j, TimeUnit.SECONDS, new LinkedBlockingDeque(), new ThreadFactory() { // from class: com.mbridge.msdk.foundation.same.e.c.1 @Override // java.util.concurrent.ThreadFactory public final Thread newThread(Runnable runnable) { Thread thread = new Thread(runnable); thread.setName("mb-task-loader-thread"); return thread; } }, new ThreadPoolExecutor.DiscardPolicy()); a.allowCoreThreadTimeOut(true); } catch (Exception e) { if (MBridgeConstans.DEBUG) { af.b("CommonTaskLoaderThreadPool", "create ThreadPoolExecutor failed ", e); } } } if (a == null) { int availableProcessors = (Runtime.getRuntime().availableProcessors() * 2) + 1; a = new ThreadPoolExecutor(availableProcessors, availableProcessors, 10L, TimeUnit.MILLISECONDS, new LinkedBlockingDeque(), new ThreadFactory() { // from class: com.mbridge.msdk.foundation.same.e.c.1 @Override // java.util.concurrent.ThreadFactory public final Thread newThread(Runnable runnable) { Thread thread = new Thread(runnable); thread.setName("mb-task-loader-thread"); return thread; } }, new ThreadPoolExecutor.DiscardPolicy()); a.allowCoreThreadTimeOut(true); } return a; } }