// matrix multiplication using threads public class mm1 { // find out number of physical cores/processors available. static int cores = Runtime.getRuntime().availableProcessors(); // conventional solution, assume square matrix for simplicity. static void mm0(double[][] A, double[][] B, double[][] R) // writes to R { int N = A.length; // assume same as A[0].length, B.length, R.length, etc for(int i = 0;i0) N = Integer.parseInt(av[0]); // create arrays double[][] A = new double[N][N]; double[][] B = new double[N][N]; double[][] R = new double[N][N]; randomize(A,N); randomize(B,N); // testing conventional solution long t1 = System.currentTimeMillis(); // record time mm0(A,B,R); long t2 = System.currentTimeMillis(); // record time System.out.println("conventional solution time: "+(t2-t1)+"ms"); System.out.println("number of CPU cores: "+cores); System.out.flush(); t1 = System.currentTimeMillis(); // record time for threaded solution try { // create worker threads Thread[] Ts = new Thread[cores]; // keep track of threads created. int Rs = N/cores; // number of rows to assign to each thread for(int w=0;w