When you execute the
ForkJoinTask objects in a
ForkJoinPool class, you can cancel them before they start their execution. The
ForkJoinTask class provides the
cancel() method for this purpose. There are some points you have to take into account when you want to cancel a task, which are as follows:
ForkJoinPoolclass doesn't provide any method to cancel all the tasks it has running or waiting in the pool
In this recipe, you will implement an example of cancelation of
ForkJoinTask objects. You will look for the position of a number in an array. The first task that finds the number will cancel the remaining tasks. As that functionality is not provided by the ...