package e4;

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

/* JADX INFO: loaded from: classes.dex */
public final class l implements Executor {

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public static final Logger f12467v = Logger.getLogger(l.class.getName());

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final Executor f12468q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final ArrayDeque f12469r = new ArrayDeque();

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f12470s = 1;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public long f12471t = 0;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final G3.b f12472u = new G3.b(this);

    public l(Executor executor) {
        w.f(executor);
        this.f12468q = executor;
    }

    @Override // java.util.concurrent.Executor
    public final void execute(Runnable runnable) {
        w.f(runnable);
        synchronized (this.f12469r) {
            int i = this.f12470s;
            if (i != 4 && i != 3) {
                long j8 = this.f12471t;
                RunnableC0880k runnableC0880k = new RunnableC0880k(runnable, 0);
                this.f12469r.add(runnableC0880k);
                this.f12470s = 2;
                try {
                    this.f12468q.execute(this.f12472u);
                    if (this.f12470s != 2) {
                        return;
                    }
                    synchronized (this.f12469r) {
                        try {
                            if (this.f12471t == j8 && this.f12470s == 2) {
                                this.f12470s = 3;
                            }
                        } finally {
                        }
                    }
                    return;
                } catch (Error | RuntimeException e8) {
                    synchronized (this.f12469r) {
                        try {
                            int i5 = this.f12470s;
                            boolean z8 = true;
                            if ((i5 != 1 && i5 != 2) || !this.f12469r.removeLastOccurrence(runnableC0880k)) {
                                z8 = false;
                            }
                            if (!(e8 instanceof RejectedExecutionException) || z8) {
                                throw e8;
                            }
                        } finally {
                        }
                    }
                    return;
                }
            }
            this.f12469r.add(runnable);
        }
    }

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