if (r > 0) {
System.out.println("Iteration " + r);
}
GlobalObject global = new GlobalObject( new Matrix(n) );
UserThread fork;
Join join = new Join();
long start = System.currentTimeMillis();
// Start n*n threads to compute each entry of the result matrix
Iterator e = PE.roundRobin();
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) {
fork = new UserThread(global, i, j, n);
fork.start((PE)e.next(), join);
}
join.waitFor();
// Print out the result
Matrix matrix = (Matrix) global.open("r");
System.out.println("The result matrix is: ");
System.out.println(matrix);
try { global.release(); } catch (AlephException x) {}
System.out.println("Elapsed time: " +
((double) (System.currentTimeMillis() - start)) / 1000.0
+ " seconds");
System.out.flush();
}