Markou moment
This commit is contained in:
parent
8fb402c420
commit
e74ed9dbca
@ -14,7 +14,7 @@ public class ParallelMax
|
|||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
// Create a list
|
// Create a list
|
||||||
final int N = 200000000;
|
final int N = 20;
|
||||||
int[] list = new int[N];
|
int[] list = new int[N];
|
||||||
for (int i = 0; i < list.length; i++)
|
for (int i = 0; i < list.length; i++)
|
||||||
list[i] = i;
|
list[i] = i;
|
||||||
@ -51,7 +51,7 @@ public class ParallelMax
|
|||||||
extends RecursiveTask<Integer>
|
extends RecursiveTask<Integer>
|
||||||
{
|
{
|
||||||
|
|
||||||
private final static int THRESHOLD = 25000;
|
private final static int THRESHOLD = 3;
|
||||||
|
|
||||||
|
|
||||||
private int[] list;
|
private int[] list;
|
||||||
@ -81,9 +81,13 @@ public class ParallelMax
|
|||||||
{
|
{
|
||||||
int mid = (low + high) / 2;
|
int mid = (low + high) / 2;
|
||||||
RecursiveTask<Integer> left = new MaxTask(list, low, mid);
|
RecursiveTask<Integer> left = new MaxTask(list, low, mid);
|
||||||
|
System.out.println("left: " + low +", " + high);
|
||||||
RecursiveTask<Integer> right = new MaxTask(list, mid+1, high);
|
RecursiveTask<Integer> right = new MaxTask(list, mid+1, high);
|
||||||
|
System.out.println("right: " + (mid + 1) +", " + high);
|
||||||
|
System.out.println("fork right");
|
||||||
right.fork();
|
right.fork();
|
||||||
left.fork();
|
System.out.println("fork left");
|
||||||
|
left.fork();
|
||||||
return new Integer(Math.max( left.join().intValue(),
|
return new Integer(Math.max( left.join().intValue(),
|
||||||
right.join().intValue())
|
right.join().intValue())
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user