package com.google.android.gms.internal.ads;

import android.os.SystemClock;

/* JADX INFO: loaded from: classes2.dex */
public final class nn0 {

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

    public final synchronized boolean a() {
        if (this.f14669a) {
            return false;
        }
        this.f14669a = true;
        notifyAll();
        return true;
    }

    public final synchronized void b() {
        boolean z10 = false;
        while (!this.f14669a) {
            try {
                wait();
            } catch (InterruptedException unused) {
                z10 = true;
            }
        }
        if (z10) {
            Thread.currentThread().interrupt();
        }
    }

    public final synchronized boolean c(long j10) {
        if (j10 > 0) {
            try {
                long jElapsedRealtime = SystemClock.elapsedRealtime();
                long j11 = j10 + jElapsedRealtime;
                if (j11 < jElapsedRealtime) {
                    b();
                } else {
                    boolean z10 = false;
                    while (!this.f14669a && jElapsedRealtime < j11) {
                        try {
                            wait(j11 - jElapsedRealtime);
                        } catch (InterruptedException unused) {
                            z10 = true;
                        }
                        jElapsedRealtime = SystemClock.elapsedRealtime();
                    }
                    if (z10) {
                        Thread.currentThread().interrupt();
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return this.f14669a;
    }
}
