package org.greenrobot.eventbus;

/* JADX INFO: compiled from: PendingPostQueue.java */
/* JADX INFO: loaded from: classes.dex */
final class k {
    private j a;
    private j b;

    k() {
    }

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

    synchronized j b() {
        j jVar;
        jVar = this.a;
        if (this.a != null) {
            j jVar2 = this.a.c;
            this.a = jVar2;
            if (jVar2 == null) {
                this.b = null;
            }
        }
        return jVar;
    }

    synchronized j c(int i2) throws InterruptedException {
        if (this.a == null) {
            wait(i2);
        }
        return b();
    }
}
