Question: using java Questionl (50 points). Using JAVA Threads and the Join method: We need to write a Java program that allows us to calculate the

using java
Questionl (50 points). Using JAVA Threads and the Join method: We need to write a Java program that allows us to calculate the average price of items in a shop The program will create two Threads as follows: 1. Main thread: a. Asks the user to enter the price of 5 items, and store these prices in an array (double not integer) b. Creates. starts and synchronizes the necessary threads. c. Displays the number of prices above the average and the number of prices below the average (using the DataCalculator Thread) 2. DataCalculator Thread: The thread receives three parameters. The first parameters a reference to an array of double values. "The econd parameter is a double value called "num". The third parameter is a Boolean called *'isAbove If isAbove is true, the thread will calculate the number of values in the array that are greater than num. Otherwise, the thread calculates the number of values that are below num Notes: 1. You should use thejoin method to synchronize the threads. (Do not use semaphore) 2. It is your responsibility to know when to use the join method to get correct results in the fastest way. Sample Run: (The underlined values are entered by the user) Enter 5 prices: 80 90 70 60 80 Number of prices above average: 3 Number of prices below average: 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
