package com.vungle.ads.internal.util; import android.os.Handler; import android.os.Looper; import androidx.annotation.VisibleForTesting; import java.util.concurrent.Executor; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes4.dex */ public final class ThreadUtil { public static final ThreadUtil INSTANCE = new ThreadUtil(); private static final Handler UI_HANDLER = new Handler(Looper.getMainLooper()); private static Executor uiExecutor; @VisibleForTesting public static /* synthetic */ void getUiExecutor$vungle_ads_release$annotations() { } public final Executor getUiExecutor$vungle_ads_release() { return uiExecutor; } public final void setUiExecutor$vungle_ads_release(Executor executor) { uiExecutor = executor; } private ThreadUtil() { } public final boolean isMainThread() { Looper mainLooper = Looper.getMainLooper(); if (mainLooper == null) { return false; } return mainLooper.isCurrentThread(); } public final void runOnUiThread(Runnable runnable) { Intrinsics.checkNotNullParameter(runnable, "runnable"); if (isMainThread()) { runnable.run(); return; } Executor executor = uiExecutor; if (executor == null) { UI_HANDLER.post(runnable); } else if (executor != null) { executor.execute(runnable); } } }