0

Excuse me for my bad english. When the number of threads in the pool to rise above 10, the the task will be placed in ArrayBlockingQueue . But if the task Callable? Constructor ThreadPoolExecutor not accept ArrayBlockingQueue typed as Callable. How, then, will be added to the queue the task?

ExecutorService executorService = new ThreadPoolExecutor(2, 10,
                60L, TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(100));
kulmerov
  • 3
  • 1

1 Answers1

0

What happens is that ThreadPoolExecutor does not add your Callable to the queue directly. Instead, it will wrap the Callable into a RunnableFuture via a call to the method AbstractExecutorService.newTaskFor(Callable), then add this RunnableFutureto the queue.

Lolo
  • 4,277
  • 2
  • 25
  • 24