package org.greenrobot.eventbus;

/* JADX INFO: compiled from: PendingPostQueue.java */
/* JADX INFO: loaded from: classes.dex */
final class i {

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

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

    i() {
    }

    synchronized void a(h hVar) {
        try {
            if (hVar == null) {
                throw new NullPointerException("null cannot be enqueued");
            }
            h hVar2 = this.f3369b;
            if (hVar2 != null) {
                hVar2.f3367d = hVar;
                this.f3369b = hVar;
            } else {
                if (this.f3368a != null) {
                    throw new IllegalStateException("Head present, but no tail");
                }
                this.f3369b = hVar;
                this.f3368a = hVar;
            }
            notifyAll();
        } catch (Throwable th) {
            throw th;
        }
    }

    synchronized h b() {
        h hVar;
        hVar = this.f3368a;
        if (hVar != null) {
            h hVar2 = hVar.f3367d;
            this.f3368a = hVar2;
            if (hVar2 == null) {
                this.f3369b = null;
            }
        }
        return hVar;
    }

    synchronized h c(int i) throws InterruptedException {
        if (this.f3368a == null) {
            wait(i);
        }
        return b();
    }
}
