Question: The java program contains an incomplete findMin method, which is designed to find the smallest element in an array. You are to complete the method
The java program contains an incomplete findMin method, which is designed to find the smallest element in an array. You are to complete the method by creating Thread objects that operate on different sections of the array and combine the results. Be sure to consider the case of arrays in which the number of elements is not a multiple of the number of Threads created.
/** Exercise to use multi-threaded programming in finding the smallest element in an array. */ public class ParallelHW1 { public static final int NUM_THREADS = 4; public static final int SIZE1 = 12; public static final int SIZE2 = 15; public static void main(String[] args) { int [] array1 = {10, 20, 30, 40, 50, 0, 70, 80, 90, 100, 110, 120}; int [] array2 = {10, 20, 30, 40, 50, 60, 70, 80, 90, -10, 110, 120, 0, -20, -5}; System.out.println(findMin(array1, SIZE1)); System.out.println(findMin(array2, SIZE2)); } /** Creates multiple threads to find the smallest value in an array @param array1 array of values to be processed @param length number of array elements */ public static int findMin(int[] array1, int length) { // Code goes Here //Donot change anything else. } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
