Question: Question2 Semaphores: We need to write a Java program that allows us to calculate the average grade in an array. However, before calculating the average,

Question2 Semaphores: We need to write a Java program that allows us to calculate the average grade in an array. However, before calculating the average, we need to make sure that all the grades are between 0 and 100 inclusive. The program will create Three Threads as follows: 1. Initializer Thread: a. Ask the user to enter the size of the array. b. Create the shared int array with the specified size, and fill it with random numbers between -50 and 150 inclusive. c. Waits for the CorrectorThread to finish correcting the values in the shared array, then, calculates and displays the average of all grades in the array. 2. CorrectorThread: 2. searches for all the values that are not between 0 and 100 in the shared array. and replaces them with 0. 3. Main thread: a. Creates the necessary semaphores b. Creates and starts the necessary threads Notes: 1. You should NOT use the join method. The threads will synchronize themselves using semaphores 2. It is your responsibility to know what are the shared variables and semaphores between the threads, and how to share them
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
