How it works...

In the entire execution of this example, we always obtained a smaller execution time for the executor than creating the thread directly. If your application has to execute a lot of tasks, better employ an executor.

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.