I'm trying to multiply two matrices using threads in Java. I don't know what's happening with my code, because it doesn't show the product of matrices, instead it shows 0 or the memory position for my MatrixC. Here's my thread-multiplication code:
public class ThreadMatrix extends Thread {
int ini, end, counter;
// Interval for each thread
public ThreadMatrizes(int ini, int end) {
this.init = ini; // Position of the matrix where the thread starts
this.end = end; // Position of the matrix where the thread ends
}
public void run(){
int i = 0, j = 0, k = 0;
for (i = init; i < end; i++){
for (j= init; j < end; j++){
for (k = init; k < end; k++){
MatrixMultiplication.matrixC[i][j] += MatrixMultiplication.matrixA[i][k]*MatrixMultiplication.matrixB[k][j];
}
}
}
System.out.println(MatrixMultiplication.matrixC[i][j]);
}
}
System.out.prinln(MatrixMultiplication.matrixC[i][j]);
なしで実行しようとしましたが、[i][j]
出力はメモリ位置です。私は何をすべきか?