title: how to find max value of the two-dimensional array in java using multithreading
body: <p>I want to find the maximum value of the two-dimensional array. I found this value without using multithreading. How do I find the maximum value of the two-dimensional array using multithreading? I want to compare the speed of finding the maximum value of the array in different ways.</p>
  
  <pre><code>public class Search {
  
      public int[][] fillMatrix(int matrix[][]) {
          for (int i = 0; i &lt; matrix.length; i++){
              for (int j = 0; j &lt; matrix[i].length; j++){
                matrix[i][j] = (int)(Math.random() * 1000);
              }
          }
          return matrix;
      }
  
      public int searchMaxValue(int[][] matrix, int row, int column) {
          int max = matrix[0][0];
          for (int a = 0; a &lt; row; a++) {
              for (int b = 0; b &lt; column; b++) {
                  try {
                      Thread.sleep(1);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
                  if (matrix[a][b] &gt; max) {
                      max = matrix[a][b];
                  }
              }
          }
          return max;
      }
  
  
      public static void main(String[] args) {
  
          Search search = new Search();
          int[][] matrix = new int[4][100];
          search.fillMatrix(matrix);
          long start = System.currentTimeMillis();
          int max = search.searchMaxValue(matrix, 4, 100);
          long end = System.currentTimeMillis();
          System.out.println("Max value is " + max);
          System.out.println("Time for execution: " + (end - start));
      }
  }
  </code></pre>