Follow these steps to implement the example:
- Create a class named Task. Specify that it implements the RecursiveTask class, parameterized with the Integer class:
public class Task extends RecursiveTask<Integer> {
- Declare a private int array named array. It will simulate the array of data you are going to process in this example:
private int array[];
- Declare two private int attributes named start and end. These attributes will determine the elements of the array this task has to process:
private int start, end;
- Implement the constructor of the class that initializes its attributes:
public Task(int array[], int start, int end){ this.array=array; this.start=start; this.end=end; }
- Implement the compute()