class MatMult extends Thread {
static int m1[][];
static int m2[][];
static int out[][];
static int n = 2;
int row;
MatMult(int i) {
row = i;
this.start();
}
public void run() {
int i, j;
for (i = 0; i < n; i++) {
out[row][i] = 0;
for (j = 0; j < n; j++) {
out[row][i] = out[row][i] + m1[row][j] * m2[j][i];
}
}
}
public static void main(String args[]) throws Exception {
int i, j;
int n = 2;
m1 = new int[][] { { 1, 2 }, { 3, 4 } };
m2 = new int[][] { { 1, 2 }, { 3, 4 } };
out = new int[n][n];
MatMult mat[] = new MatMult[n];
for (i = 0; i < n; i++) {
mat[i] = new MatMult(i);
}
for (i = 0; i < n; i++) {
mat[i].join();
}
System.out.println("OUTPUT :");
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
System.out.print(out[i][j] + "\t");
}
System.out.println();
}
}
}

Here's my multi threaded version of mat-mat mult.

In this example,