Question: PLEASE HELP URGENT In this project, you will develop a multithreaded program for calculating the summation of elements in an array. The program uses mutex

PLEASE HELP URGENT
In this project, you will develop a multithreaded program for calculating the summation of elements in an array. The program uses mutex lock for synchronization. To use multi-threaded programing, the array of integers is divided into two smaller sublists. Two separate threads add the elements in the first half and second half of the array to the summation. To demonstrate the benefits of synchronization for multi-threaded program, the program repeats the procedure for 100 times where the results should always be the same.
This program will require the two threads share the same variable of summation. Summing the elements of the sublists to a local variable can be concurrent. But adding the results to the summation should be synchronized.
Program Structure
The program consists of the following Classes:
1. SynchronizationDemo: main method performs the following tasks:
1) Generate an integer array whose 100 elements are 1,2, 3,... 100
2) Repeat the following 100 times:
i. Create two threads for the class Sum and use them to calculate the summation of the 100 elements. The first thread adds the first 50 elements to the summation, and the second thread adds the second 50 elements to the summation.
ii. Display the summation.
2. Sum: an inner class that implements Runnable interface. run method performs the following tasks:
1) Calculate the total of the elements from index start to index end
2) Call Thread.sleep(5) to pause the thread
3) Add the total to summation

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!