I have to create exactly 2 classes: Main with main method, and other one, let's say Class1 that implements matrix multiplication. I want Class1 to read data from file, and perform matrix multiplication using threads.
I know I can create multiple instances and pass parameter to constructors, but what I need is to create one instance of Class1 and read file once, and run portion of calculation on multiple threads.
It's incorrect, but it should kind of have passing run method with parameter:
public class Main {
public static void main(String[] args) {
Class1 c = new Class1();
ArrayList <Thread> a = new ArrayList<>();
for (int i = 0; i < 4; i++) {
a.add(i, new Thread(c));
}
for (int i = 0; i < 4; i++) {
a.get(i).start(index1,index2);
}
}
}