package com.mbridge.msdk.dycreator.bus;

import android.util.Log;
/* loaded from: classes5.dex */
final class BackgroundPoster implements Runnable {

    /* renamed from: a  reason: collision with root package name */
    private final PendingPostQueue f3493a = new PendingPostQueue();
    private volatile boolean b;
    private final EventBus c;

    /* JADX INFO: Access modifiers changed from: package-private */
    public BackgroundPoster(EventBus eventBus) {
        this.c = eventBus;
    }

    public final void enqueue(Subscription subscription, Object obj) {
        PendingPost a2 = PendingPost.a(subscription, obj);
        synchronized (this) {
            this.f3493a.a(a2);
            if (!this.b) {
                this.b = true;
                EventBus.f3494a.execute(this);
            }
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        while (true) {
            try {
                PendingPost a2 = this.f3493a.a(1000);
                if (a2 == null) {
                    synchronized (this) {
                        a2 = this.f3493a.a();
                        if (a2 == null) {
                            return;
                        }
                    }
                }
                this.c.a(a2);
            } catch (InterruptedException e) {
                Log.w("Event", Thread.currentThread().getName() + " was interruppted", e);
                return;
            } finally {
                this.b = false;
            }
        }
    }
}
