package com.pgl.ssdk;

import android.os.HandlerThread;
import java.lang.ref.WeakReference;
/* loaded from: classes6.dex */
public class M {

    /* renamed from: a  reason: collision with root package name */
    private final P<N> f4744a;
    private Q b;

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes6.dex */
    public static class b {

        /* renamed from: a  reason: collision with root package name */
        private static final M f4745a = new M();
    }

    public static M a() {
        return b.f4745a;
    }

    private M() {
        this.f4744a = P.a(2);
    }

    public Q a(String str) {
        N a2 = this.f4744a.a();
        if (a2 != null) {
            a2.f4747a = new WeakReference<>(null);
            a2.a(str);
            return a2;
        }
        if (!H.b().a()) {
            try {
                HandlerThread handlerThread = new HandlerThread(str);
                handlerThread.start();
                return new N(handlerThread, null);
            } catch (Throwable unused) {
            }
        }
        return null;
    }

    public Q b() {
        if (this.b == null) {
            synchronized (M.class) {
                if (this.b == null) {
                    this.b = a("ssdk_net_handler");
                }
            }
        }
        return this.b;
    }

    public Q c() {
        if (this.b == null) {
            synchronized (M.class) {
                if (this.b == null) {
                    this.b = a("ssdk_handler");
                }
            }
        }
        return this.b;
    }
}
