网站建设费按多少年摊销,电商网站如何提高转化率,图片设计师网站,网站后期一、jdk中默认线程池中的代理模式 单例类线程池只有一个线程#xff0c;无边界队列#xff0c;适合cpu密集的运算。jdk中创建线程池是通过Executors类中提供的静态的方法来创建的#xff0c;其中的单例类线程池的方法如下#xff1a; public static ExecutorService newSin…一、jdk中默认线程池中的代理模式 单例类线程池只有一个线程无边界队列适合cpu密集的运算。jdk中创建线程池是通过Executors类中提供的静态的方法来创建的其中的单例类线程池的方法如下 public static ExecutorService newSingleThreadExecutor()
{return new FinalizableDelegatedExecutorService(new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()));
}public static ScheduledExecutorService newSingleThreadScheduledExecutor()
{return new DelegatedScheduledExecutorService(new ScheduledThreadPoolExecutor(1));
} 说明 1、newSingleThreadExecutor的代理模式类图如下 new ThreadPoolExecutor()实例是被代理对象作为参数传给代理对象FinalizableDelegatedExecutorService通过代理对象限制对ThreadPoolExecutor进行参数化调整。2、newSingleThreadScheduledExecutor的代理模式类图如下 new ScheduledThreadPoolExecutor(1)实例是被代理对象作为参数传递给代理对象DelegatedScheduledExecutorService通过代理对象限制对ThreadPoolExecutor进行参数化调整。