0

Full code

import java.util.ArrayList;
import java.util.List;

public class ParallelThreadsCreator {
    public static void multiply(int[][] matrix1, int[][] matrix2, int[][] result) {
        List threads = new ArrayList<>();
        int rows1 = matrix1.length;
        for (int i = 0; i < rows1; i++) {
            Logic task = new Logic(result, matrix1, matrix2, i);
            Thread thread = new Thread(task);
            thread.start();
            threads.add(thread);
            if (threads.size() % 10 == 0) {
                waitForThreads(threads);
            }
        }
    }
    
    private static void waitForThreads(List threads) {
        for (Thread thread : threads){
            try {
                thread.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        threads.clear();
    }

}

I'm getting error for the waitForThreads method, i can't figure out what did i do wrong. Did i implement the For-Each loop wrongly?

enter image description here

Lorale
  • 103
  • 6

0 Answers0