There's more...

If you use the get() method of a Future object that controls a task that has been canceled, the get() method will throw a CancellationException exception.

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.