package com.dowse.base.log;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/* loaded from: ds_base_2.0.9_23030112.aar:classes.jar:com/dowse/base/log/ThreadPoolTools.class */
public class ThreadPoolTools {
    private static final int MAX_THREAD = 3;
    private static ExecutorService executorService;
    private static ExecutorService single;

    private ThreadPoolTools() {
    }

    public static void post(Runnable runnable) {
        if (executorService != null && (executorService.isShutdown() || executorService.isTerminated())) {
            executorService = null;
        }
        if (executorService == null) {
            synchronized (ThreadPoolTools.class) {
                if (executorService == null) {
                    executorService = Executors.newWorkStealingPool(3);
                }
            }
        }
        executorService.execute(runnable);
    }

    public static void singleThread(Runnable runnable) {
        if (single == null || single.isShutdown() || single.isTerminated()) {
            synchronized (ThreadPoolTools.class) {
                single = Executors.newSingleThreadExecutor();
            }
        }
        single.execute(runnable);
    }
}
