package o;

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

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class E7 implements Executor {
    public final /* synthetic */ int l;
    public final ArrayDeque m;
    public Runnable n;

    /* renamed from: o, reason: collision with root package name */
    public final Object f98o;
    public final Executor p;

    public E7(Executor executor) {
        this.l = 1;
        this.p = executor;
        this.m = new ArrayDeque();
        this.f98o = new Object();
    }

    public final void a() {
        switch (this.l) {
            case 0:
                synchronized (this.f98o) {
                    try {
                        Runnable runnable = (Runnable) this.m.poll();
                        this.n = runnable;
                        if (runnable != null) {
                            ((ExecutorC0614Xr) this.p).execute(runnable);
                        }
                    } catch (Throwable th) {
                        throw th;
                    }
                }
                return;
            default:
                Runnable runnable2 = (Runnable) this.m.poll();
                this.n = runnable2;
                if (runnable2 != null) {
                    this.p.execute(runnable2);
                    return;
                }
                return;
        }
    }

    @Override // java.util.concurrent.Executor
    public final void execute(Runnable runnable) {
        switch (this.l) {
            case 0:
                synchronized (this.f98o) {
                    try {
                        this.m.add(new O3(1, this, runnable));
                        if (this.n == null) {
                            a();
                        }
                    } finally {
                    }
                }
                return;
            default:
                synchronized (this.f98o) {
                    try {
                        this.m.add(new RunnableC0890cD(14, this, runnable));
                        if (this.n == null) {
                            a();
                        }
                    } finally {
                    }
                }
                return;
        }
    }

    public E7(ExecutorC0614Xr executorC0614Xr) {
        this.l = 0;
        this.f98o = new Object();
        this.m = new ArrayDeque();
        this.p = executorC0614Xr;
    }
}
