package O1;

/* JADX INFO: loaded from: classes2.dex */
final class k {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private j f1529a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private j f1530b;

    k() {
    }

    synchronized void a(j jVar) {
        try {
            if (jVar == null) {
                throw new NullPointerException("null cannot be enqueued");
            }
            j jVar2 = this.f1530b;
            if (jVar2 != null) {
                jVar2.f1528c = jVar;
                this.f1530b = jVar;
            } else {
                if (this.f1529a != null) {
                    throw new IllegalStateException("Head present, but no tail");
                }
                this.f1530b = jVar;
                this.f1529a = jVar;
            }
            notifyAll();
        } catch (Throwable th) {
            throw th;
        }
    }

    synchronized j b() {
        j jVar;
        jVar = this.f1529a;
        if (jVar != null) {
            j jVar2 = jVar.f1528c;
            this.f1529a = jVar2;
            if (jVar2 == null) {
                this.f1530b = null;
            }
        }
        return jVar;
    }

    synchronized j c(int i2) {
        try {
            if (this.f1529a == null) {
                wait(i2);
            }
        } catch (Throwable th) {
            throw th;
        }
        return b();
    }
}
