package com.crm.ib.task.configuration;

import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by max on 2020/6/18.
 */
@Component
public class ThreadPoolConfig {

    @Bean
    public ListeningExecutorService listeningExecutorService() {
        ThreadPoolExecutor threadPoolExecutor =
                new ThreadPoolExecutor(4, 8, 0L, TimeUnit.SECONDS, new LinkedBlockingDeque<>());

        return MoreExecutors.listeningDecorator(threadPoolExecutor);
    }

}
