package defpackage;

import java.util.ArrayDeque;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.logging.Logger;

/* renamed from: ᵻᵤ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class ExecutorC5212 implements Executor {

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public static final Logger f19448 = Logger.getLogger(ExecutorC5212.class.getName());

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final Executor f19451;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final ArrayDeque f19449 = new ArrayDeque();

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public int f19453 = 1;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public long f19452 = 0;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final ᵧˀ f19450 = new ᵧˀ(this);

    public ExecutorC5212(Executor executor) {
        ᵩʛʽ.ᵝᵵᵺ(executor);
        this.f19451 = executor;
    }

    @Override // java.util.concurrent.Executor
    public final void execute(Runnable runnable) {
        ᵩʛʽ.ᵝᵵᵺ(runnable);
        synchronized (this.f19449) {
            int i = this.f19453;
            if (i != 4 && i != 3) {
                long j = this.f19452;
                RunnableC0504 runnableC0504 = new RunnableC0504(runnable, 2);
                this.f19449.add(runnableC0504);
                this.f19453 = 2;
                try {
                    this.f19451.execute(this.f19450);
                    if (this.f19453 != 2) {
                        return;
                    }
                    synchronized (this.f19449) {
                        try {
                            if (this.f19452 == j && this.f19453 == 2) {
                                this.f19453 = 3;
                            }
                        } finally {
                        }
                    }
                    return;
                } catch (Error | RuntimeException e) {
                    synchronized (this.f19449) {
                        try {
                            int i2 = this.f19453;
                            boolean z = true;
                            if ((i2 != 1 && i2 != 2) || !this.f19449.removeLastOccurrence(runnableC0504)) {
                                z = false;
                            }
                            if (!(e instanceof RejectedExecutionException) || z) {
                                throw e;
                            }
                        } finally {
                        }
                    }
                    return;
                }
            }
            this.f19449.add(runnable);
        }
    }

    public final String toString() {
        return "SequentialExecutor@" + System.identityHashCode(this) + "{" + this.f19451 + "}";
    }
}
