Cover by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Customizing the ThreadPoolExecutor class

The Executor framework is a mechanism that allows you to separate the thread creation from its execution. It's based on the Executor and ExecutorService interfaces with the ThreadPoolExecutor class that implements both interfaces. It has an internal pool of threads and provides methods that allow you to send two kinds of tasks for their execution in the pooled threads. These tasks are:

  • The Runnable interface to implement tasks that don't return a result
  • The Callable interface to implement tasks that return a result

In both cases, you only send the task to the executor. The executor uses one of its pooled threads or creates a new one to execute those tasks. The executor also decides the moment in which the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required