In this example, you used the join() method to wait for the finalization of tasks and get their results. You can also use one of the following two versions of the get() method with this purpose:
- get(): This version of the get() method returns the value returned by the compute() method if ForkJoinTask has finished its execution, or it waits until its finalization.
- get(long timeout, TimeUnit unit): This version of the get() method, if the result of the task isn't available, waits the specified time for it. If the specified period of time passes and the result isn't yet available, the method returns a null value. The TimeUnit class is an enumeration with the following constants: DAYS, HOURS, MICROSECONDS, MILLISECONDS, MINUTES ...