package nc;

import android.os.Handler;
import android.os.HandlerThread;

/* JADX INFO: loaded from: classes.dex */
public final class j {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static j f31234e;

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f31237c = 0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Object f31238d = new Object();

    public final void a() {
        synchronized (this.f31238d) {
            try {
                if (this.f31235a == null) {
                    if (this.f31237c <= 0) {
                        throw new IllegalStateException("CameraThread is not open");
                    }
                    HandlerThread handlerThread = new HandlerThread("CameraThread");
                    this.f31236b = handlerThread;
                    handlerThread.start();
                    this.f31235a = new Handler(this.f31236b.getLooper());
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void b(Runnable runnable) {
        synchronized (this.f31238d) {
            a();
            this.f31235a.post(runnable);
        }
    }
}
