( a )equalsthenumberofrowsinthesecond Matrix ( b ),whichisessentialtotheal-
gorithm, multiply() creates a Matrix named result and enters a sequence of
nested loops to perform the multiplication.
The essence of these loops is as follows: For each row in a , multiply each of that
row'scolumnvaluesbythecorrespondingcolumn'srowvaluesin b .Addtogetherthe
resultsofthemultiplications,andstoretheoveralltotalin result atthelocationspe-
cified via the row index ( i ) in a and the column index ( j ) in b .
When you run this application, it generates the following output, which indicates
1.0 2.0 3.0
Computer scientists classify this algorithm as O(n 3 ), which is read “big-oh of n-
processorspeed).AO(n 3 )classificationindicatesverypoorperformance,andthisper-
formance worsens as the sizes of the matrixes being multiplied increase.
The performance can be improved (on multiprocessor and/or multicore platforms)
by assigning each row-by-column multiplication task to a separate thread-like entity.
Listing 6-9 showsyouhowtoaccomplish thisscenario inthecontext oftheFork/Join
Listing 6-9. Multiplying two matrixes via the Fork/Join Framework
class MatMult extends RecursiveAction