首页 文章

Executors中的数据结构

提问于
浏览
1

我们可以在定义ThreadPoolExecutors时提供BlockingQueue实现 . 但是,如果我使用工厂(Executors)创建一个如下所示的线程池,我想知道使用哪个阻塞队列 . 我猜这是一个LinkedBlockingQueue . 该文档讨论了无界队列,但它没有揭示实现 .

ExectorService service = Executors.newSingleThreadExecutor();

1 回答

  • 1

    这是来自Executors src:

    public static ExecutorService newSingleThreadExecutor() {
        return new FinalizableDelegatedExecutorService
            (new ThreadPoolExecutor(1, 1,
                                    0L, TimeUnit.MILLISECONDS,
                                    new LinkedBlockingQueue<Runnable>()));
    }
    

相关问题