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

 Question2 Semaphores: We need to write a Java program that allows

Question2 Semaphores: We need to write a Java program that allows us to calculate the average value in an array. However, before calculating the average, we need to make sure that all the values are between 50 and 100 inclusive. The program will create Three Threads as follows: 1. FillerThread: 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 values in the array. 2. Corrector Thread: a. searches for all the values that are not between 50 and 100 in the shared array, and replaces them with 50. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!