package com.mbridge.msdk.dycreator.bus;
/* loaded from: classes5.dex */
final class PendingPostQueue {

    /* renamed from: a  reason: collision with root package name */
    private PendingPost f3501a;
    private PendingPost b;

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized void a(PendingPost pendingPost) {
        try {
            if (pendingPost == null) {
                throw new NullPointerException("null cannot be enqueued");
            }
            PendingPost pendingPost2 = this.b;
            if (pendingPost2 != null) {
                pendingPost2.c = pendingPost;
                this.b = pendingPost;
            } else if (this.f3501a != null) {
                throw new IllegalStateException("Head present, but no tail");
            } else {
                this.b = pendingPost;
                this.f3501a = pendingPost;
            }
            notifyAll();
        } catch (Throwable th) {
            throw th;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized PendingPost a() {
        PendingPost pendingPost;
        pendingPost = this.f3501a;
        if (pendingPost != null) {
            PendingPost pendingPost2 = pendingPost.c;
            this.f3501a = pendingPost2;
            if (pendingPost2 == null) {
                this.b = null;
            }
        }
        return pendingPost;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized PendingPost a(int i) throws InterruptedException {
        if (this.f3501a == null) {
            wait(i);
        }
        return a();
    }
}
