The Executor framework allows you to execute concurrent tasks without worrying about thread creation and execution. It provides you with the Future class, which you can use to control the status and get the results of any task executed in an executor.
When you want to wait for the finalization of a task, you can use the following two methods:
- The isDone() method of the Future interface returns true if the task has finished its execution
- The awaitTermination() method of the ThreadPoolExecutor class puts the thread to sleep until all the tasks have finished their execution after a call to the shutdown() method
These two methods have some drawbacks. With the first one, you can only control ...