Question
Problem: Implement a multithreaded solution to finding the sum of 9,000,000 double values. Description: Begin by creating a method that creates an array (not an
Problem: Implement a multithreaded solution to finding the sum of 9,000,000 double values.
Description: Begin by creating a method that creates an array (not an ArrayList) of 9000000 doubles and populates each index with a random number. Create a class to hold the sum of all the numbers in the array. Protect access to that sum by using a ReentrantLock appropriately. Make sure you use good object-oriented techniques in creating this class. Then, create a Runnable that can sum an array of any length and add that sum to a shared total. Separate the array into a minimum of 10 pieces and launch a thread to sum each of the pieces. You probably want more threads, but experiment to find the number of threads that seems to sum the quickest. When all threads are done summing their pieces, show the combined sum of all 9,000,000 pieces
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started