Data structure inside Executors

360 views Asked by At

We can provide a BlockingQueue implementations while defining ThreadPoolExecutors. However, if I use the factory (Executors) to create a single thread pool as shown below, I would like to know which blocking queue is used. I am guessing it is a LinkedBlockingQueue. The documentation talks about unbounded queue, but it does not reveal the implementation.

ExectorService service = Executors.newSingleThreadExecutor();
1

There are 1 answers

0
Evgeniy Dorofeev On BEST ANSWER

This is from Executors src:

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