Markou moment

master
Chloe Fontenot 🏳️‍⚧️ 2024-02-19 09:58:49 +07:00
parent 8fb402c420
commit e74ed9dbca
1 changed files with 7 additions and 3 deletions

@ -14,7 +14,7 @@ public class ParallelMax
public static void main(String[] args)
{
// Create a list
final int N = 200000000;
final int N = 20;
int[] list = new int[N];
for (int i = 0; i < list.length; i++)
list[i] = i;
@ -51,7 +51,7 @@ public class ParallelMax
extends RecursiveTask<Integer>
{
private final static int THRESHOLD = 25000;
private final static int THRESHOLD = 3;
private int[] list;
@ -81,9 +81,13 @@ public class ParallelMax
{
int mid = (low + high) / 2;
RecursiveTask<Integer> left = new MaxTask(list, low, mid);
System.out.println("left: " + low +", " + high);
RecursiveTask<Integer> right = new MaxTask(list, mid+1, high);
System.out.println("right: " + (mid + 1) +", " + high);
System.out.println("fork right");
right.fork();
left.fork();
System.out.println("fork left");
left.fork();
return new Integer(Math.max( left.join().intValue(),
right.join().intValue())
);