Skip to content
Snippets Groups Projects
Commit 2bb08e9f authored by Winston Jodjana's avatar Winston Jodjana
Browse files

Update LessThan7.java

parent 0a755dd9
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ import java.util.concurrent.RecursiveTask; ...@@ -8,6 +8,7 @@ import java.util.concurrent.RecursiveTask;
* Your code must have O(n) work, O(lg(n)) span, where n is the length of arr * Your code must have O(n) work, O(lg(n)) span, where n is the length of arr
*/ */
public class LessThan7 { public class LessThan7 {
// Its static so that the compiler knows to not duplicate memory when we fork.
private static final ForkJoinPool POOL = new ForkJoinPool(); private static final ForkJoinPool POOL = new ForkJoinPool();
private static final int CUTOFF = 1; private static final int CUTOFF = 1;
...@@ -22,6 +23,7 @@ public class LessThan7 { ...@@ -22,6 +23,7 @@ public class LessThan7 {
return POOL.invoke(new LessThan7Task(arr, 0, arr.length)); return POOL.invoke(new LessThan7Task(arr, 0, arr.length));
} }
// Static for the same reasons above
private static class LessThan7Task extends RecursiveTask<Integer> { private static class LessThan7Task extends RecursiveTask<Integer> {
int[] arr; int[] arr;
int lo, hi; int lo, hi;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment