package p060t1; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.LockSupport; import p048p1.C1543e; import p060t1.AbstractC1692l0; /* renamed from: t1.a0 */ /* loaded from: classes.dex */ public final class RunnableC1656a0 extends AbstractC1692l0 implements Runnable { private static volatile Thread _thread; private static volatile int debugStatus; /* renamed from: j */ public static final RunnableC1656a0 f3877j; /* renamed from: k */ public static final long f3878k; static { Long l; RunnableC1656a0 runnableC1656a0 = new RunnableC1656a0(); f3877j = runnableC1656a0; AbstractC1689k0.m566s(runnableC1656a0, false, 1, null); TimeUnit timeUnit = TimeUnit.MILLISECONDS; try { l = Long.getLong("kotlinx.coroutines.DefaultExecutor.keepAlive", 1000L); } catch (SecurityException unused) { l = 1000L; } f3878k = timeUnit.toNanos(l.longValue()); } @Override // p060t1.AbstractC1692l0 /* renamed from: C */ public void mo559C(Runnable runnable) { if (m687P()) { m684S(); } super.mo559C(runnable); } /* renamed from: N */ public final synchronized void m689N() { if (m686Q()) { debugStatus = 3; m553I(); notifyAll(); } } /* renamed from: O */ public final synchronized Thread m688O() { Thread thread; thread = _thread; if (thread == null) { thread = new Thread(this, "kotlinx.coroutines.DefaultExecutor"); _thread = thread; thread.setDaemon(true); thread.start(); } return thread; } /* renamed from: P */ public final boolean m687P() { return debugStatus == 4; } /* renamed from: Q */ public final boolean m686Q() { int i = debugStatus; return i == 2 || i == 3; } /* renamed from: R */ public final synchronized boolean m685R() { if (m686Q()) { return false; } debugStatus = 1; notifyAll(); return true; } /* renamed from: S */ public final void m684S() { throw new RejectedExecutionException("DefaultExecutor was shut down. This error indicates that Dispatchers.shutdown() was invoked prior to completion of exiting coroutines, leaving coroutines in incomplete state. Please refer to Dispatchers.shutdown documentation for more details"); } @Override // java.lang.Runnable public void run() { boolean m556F; C1687j1.f3914a.m571c(this); C1664c.m619a(); try { if (!m685R()) { if (m556F) { return; } return; } long j = Long.MAX_VALUE; while (true) { Thread.interrupted(); long m555G = m555G(); if (m555G == Long.MAX_VALUE) { C1664c.m619a(); long nanoTime = System.nanoTime(); if (j == Long.MAX_VALUE) { j = f3878k + nanoTime; } long j2 = j - nanoTime; if (j2 <= 0) { _thread = null; m689N(); C1664c.m619a(); if (m556F()) { return; } mo536w(); return; } m555G = C1543e.m1089d(m555G, j2); } else { j = Long.MAX_VALUE; } if (m555G > 0) { if (m686Q()) { _thread = null; m689N(); C1664c.m619a(); if (m556F()) { return; } mo536w(); return; } C1664c.m619a(); LockSupport.parkNanos(this, m555G); } } } finally { _thread = null; m689N(); C1664c.m619a(); if (!m556F()) { mo536w(); } } } @Override // p060t1.AbstractC1692l0, p060t1.AbstractC1689k0 public void shutdown() { debugStatus = 4; super.shutdown(); } @Override // p060t1.AbstractC1697m0 /* renamed from: w */ public Thread mo536w() { Thread thread = _thread; return thread == null ? m688O() : thread; } @Override // p060t1.AbstractC1697m0 /* renamed from: x */ public void mo535x(long j, AbstractC1692l0.AbstractRunnableC1693a abstractRunnableC1693a) { m684S(); } }