package defpackage;

import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;

/* JADX INFO: renamed from: ᵙⁱˉˀ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractRunnableC2690 extends AtomicReference implements Runnable {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public static final RunnableC3996 f10360;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public static final RunnableC3996 f10361;

    static {
        int i = 3;
        f10360 = new RunnableC3996(i);
        f10361 = new RunnableC3996(i);
    }

    @Override // java.lang.Runnable
    public final void run() {
        Thread threadCurrentThread = Thread.currentThread();
        Object objMo6484 = null;
        if (compareAndSet(null, threadCurrentThread)) {
            boolean zMo6487 = mo6487();
            RunnableC3996 runnableC3996 = f10360;
            if (!zMo6487) {
                try {
                    objMo6484 = mo6484();
                } catch (Throwable th) {
                    try {
                        if (th instanceof InterruptedException) {
                            Thread.currentThread().interrupt();
                        }
                        if (!compareAndSet(threadCurrentThread, runnableC3996)) {
                            m6486(threadCurrentThread);
                        }
                        if (zMo6487) {
                            return;
                        }
                        mo6485(th);
                        return;
                    } finally {
                        if (!compareAndSet(threadCurrentThread, runnableC3996)) {
                            m6486(threadCurrentThread);
                        }
                        if (!zMo6487) {
                            mo6482(null);
                        }
                    }
                }
            }
        }
    }

    @Override // java.util.concurrent.atomic.AtomicReference
    public final String toString() {
        String str;
        Runnable runnable = (Runnable) get();
        if (runnable == f10360) {
            str = "running=[DONE]";
        } else if (runnable instanceof RunnableC5501) {
            str = "running=[INTERRUPTED]";
        } else if (runnable instanceof Thread) {
            str = "running=[RUNNING ON " + ((Thread) runnable).getName() + "]";
        } else {
            str = "running=[NOT STARTED YET]";
        }
        return str + ", " + mo6488();
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public abstract void mo6482(Object obj);

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m6483() {
        RunnableC3996 runnableC3996 = f10361;
        RunnableC3996 runnableC39962 = f10360;
        Runnable runnable = (Runnable) get();
        if (runnable instanceof Thread) {
            RunnableC5501 runnableC5501 = new RunnableC5501(this);
            RunnableC5501.m11140(runnableC5501, Thread.currentThread());
            if (compareAndSet(runnable, runnableC5501)) {
                try {
                    ((Thread) runnable).interrupt();
                } finally {
                    if (((Runnable) getAndSet(runnableC39962)) == runnableC3996) {
                        LockSupport.unpark((Thread) runnable);
                    }
                }
            }
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public abstract Object mo6484();

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public abstract void mo6485(Throwable th);

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final void m6486(Thread thread) {
        Runnable runnable = (Runnable) get();
        RunnableC5501 runnableC5501 = null;
        boolean z = false;
        int i = 0;
        while (true) {
            boolean z2 = runnable instanceof RunnableC5501;
            RunnableC3996 runnableC3996 = f10361;
            if (!z2 && runnable != runnableC3996) {
                break;
            }
            if (z2) {
                runnableC5501 = (RunnableC5501) runnable;
            }
            i++;
            if (i <= 1000) {
                Thread.yield();
            } else if (runnable == runnableC3996 || compareAndSet(runnable, runnableC3996)) {
                z = Thread.interrupted() || z;
                LockSupport.park(runnableC5501);
            }
            runnable = (Runnable) get();
        }
        if (z) {
            thread.interrupt();
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public abstract boolean mo6487();

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public abstract String mo6488();
}
