Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use the following classes, SimpleArray ( synchronized version ) , ArrayWrite, and SharedArrayTest for this program. Rename the SharedArrayTest class as Program 9 . Change
Use the following classes, SimpleArray synchronized version ArrayWrite, and
SharedArrayTest for this program.
Rename the SharedArrayTest class as
Program Change the array size to Modified the run method to add
random numbers between to the array. Add a totalArray attribute to the
SimpleArray class to return the sum of the elements in the array.
Use a Fix Thread Pool the size of the number of CPU cores in the system and make
sure you do not populate the array past the end of it Display the CPU cores of the
system. Remove all the Thread.sleep statements in the methods of the classes
mentioned above. Also, remove all the print statements in the SimpleArray class.
Write a nonstatic method in the Program class named singleThreadedArray that
creates a simple integer array of size populate it with random numbers
between and return the sum of the members.
Write a nonstatic method in the Program class named compareTimes. Use the
DateTime API timing techniques described in Section to compare the time
required for both modules the MultiThreaded and the SingleThreaded to run.
All classes in this program must be public, nonstatic and not nested in other
classes.
No input, processing or output should happen in the main method. All work in
the test class should be delegated to other methods in the class.
Every method in your program should be limited to performing a single, well
defined task, and the name of the method should express that task effectively.
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