Answered step by step
Verified Expert Solution
Link Copied!

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
Program9. Change the array size to 15,000,000. Modified the run method to add
random numbers (between 1-20) 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 non-static method in the Program9 class named singleThreadedArray that
creates a simple integer array of size 15,000,000, populate it with random numbers
(between 1-20), and return the sum of the members.
Write a non-static method in the Program9 class named compareTimes. Use the
Date/Time API timing techniques described in Section 23.12 to compare the time
required for both modules (the Multi-Threaded and the Single-Threaded) to run.
All classes in this program must be public, non-static 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions