package util;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.*;
public class ThreadManage {
private static ExecutorService executorService=getExecutorService();
private static ExecutorService executorService2=test();
public static ExecutorService getExecutorService(){
ThreadFactory nameThreadFactory=new ThreadFactoryBuilder().setNameFormat("thread-pool-cuhome-%d").build();
ExecutorService executorService1=new ThreadPoolExecutor(4,8,3000, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>(1024),nameThreadFactory,new ThreadPoolExecutor.AbortPolicy());
return executorService1;
}
private static ScheduledExecutorService test(){
ThreadFactory threadFactory=new ThreadFactoryBuilder().setNameFormat("thread-schdule-%d").build();
ScheduledExecutorService scheduledExecutorService=new ScheduledThreadPoolExecutor(1,threadFactory);
return scheduledExecutorService;
}
}
线程池的2种构造方式
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
javascript 将图片转换为data
七个方法,基本覆盖了JS中大部分文件类型的转换
javascript 前端 开发语言 字符串 Image