package d.h.f;

/* JADX INFO: loaded from: classes.dex */
public final class a {
    public boolean a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public InterfaceC0031a f2665b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f2666c;

    /* JADX INFO: renamed from: d.h.f.a$a, reason: collision with other inner class name */
    public interface InterfaceC0031a {
        void a();
    }

    public void a() {
        synchronized (this) {
            if (this.a) {
                return;
            }
            this.a = true;
            this.f2666c = true;
            InterfaceC0031a interfaceC0031a = this.f2665b;
            if (interfaceC0031a != null) {
                try {
                    interfaceC0031a.a();
                } catch (Throwable th) {
                    synchronized (this) {
                        this.f2666c = false;
                        notifyAll();
                        throw th;
                    }
                }
            }
            synchronized (this) {
                this.f2666c = false;
                notifyAll();
            }
        }
    }

    public void b(InterfaceC0031a interfaceC0031a) {
        synchronized (this) {
            while (this.f2666c) {
                try {
                    wait();
                } catch (InterruptedException unused) {
                }
            }
            if (this.f2665b == interfaceC0031a) {
                return;
            }
            this.f2665b = interfaceC0031a;
            if (this.a) {
                interfaceC0031a.a();
            }
        }
    }
}
