package com.android.launcher3.util;

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadpoolManager {

    private static volatile ThreadpoolManager mInstacne;

    private ThreadPoolExecutor mPoolExecutor;

    public static ThreadpoolManager getInstance() {
        if (mInstacne == null) {
            synchronized (ThreadpoolManager.class) {
                if (mInstacne == null) {
                    mInstacne = new ThreadpoolManager();
                }
            }
        }
        return mInstacne;
    }

    private ThreadpoolManager() {
        mPoolExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>());
    }


    public void execute(Runnable task){
        mPoolExecutor.execute(task);
    }
}
