How it works...
The first point to take into consideration to understand this example is the difference between the submit() method of the ThreadPoolExecutor class when you pass a Callable object as the parameter and the submit() method when you pass a Runnable object as the parameter. In the first case, you can use the Future object that this method returns to control the status of the task and to get its result. But in the second case, when you pass a Runnable object, you can only use the Future object that this method returns to control the status of the task. If you call the get() method of that Future object, you will get a null value.
To override this behavior, you have implemented the Task class. This class extends the FutureTask
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access