package defpackage;

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

/* renamed from: ᵼᵳˋˀ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class ExecutorC5302 implements Executor {

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public static final C5081 f19842 = new C5081(0, ExecutorC5302.class);

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

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

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

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

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final ᵔᵨᵗ f19844 = new ᵔᵨᵗ(this);

    public ExecutorC5302(Executor executor) {
        executor.getClass();
        this.f19845 = executor;
    }

    @Override // java.util.concurrent.Executor
    public final void execute(Runnable runnable) {
        runnable.getClass();
        synchronized (this.f19843) {
            int i = this.f19847;
            if (i != 4 && i != 3) {
                long j = this.f19846;
                RunnableC0504 runnableC0504 = new RunnableC0504(runnable, 3);
                this.f19843.add(runnableC0504);
                this.f19847 = 2;
                try {
                    this.f19845.execute(this.f19844);
                    if (this.f19847 != 2) {
                        return;
                    }
                    synchronized (this.f19843) {
                        try {
                            if (this.f19846 == j && this.f19847 == 2) {
                                this.f19847 = 3;
                            }
                        } finally {
                        }
                    }
                    return;
                } catch (Throwable th) {
                    synchronized (this.f19843) {
                        try {
                            int i2 = this.f19847;
                            boolean z = true;
                            if ((i2 != 1 && i2 != 2) || !this.f19843.removeLastOccurrence(runnableC0504)) {
                                z = false;
                            }
                            if (!(th instanceof RejectedExecutionException) || z) {
                                throw th;
                            }
                            return;
                        } finally {
                        }
                    }
                }
            }
            this.f19843.add(runnable);
        }
    }

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