package com.elab.log.factory;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.junit.Test;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Module TODO
 * @Description TODO
 * @Author liukaixiong
 * @Date 2021/1/15 18:43
 */
public class CatThreadFactoryTest   {
    ExecutorService executorService = new ThreadPoolExecutor(1, 50,
            0L, TimeUnit.MILLISECONDS,
            new ArrayBlockingQueue<>(5000), new ThreadFactoryBuilder().setThreadFactory(new CatThreadFactory()).setNameFormat("async_handle_%d").setDaemon(false).build());

    @Test
    public void newThread() throws Exception {
        for (int i = 0; i < 100; i++) {
            executorService.execute(() -> {
                System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            });
        }
        System.in.read();

    }
}