Question: Use the following classes, SimpleArray ( synchronized version ) , ArrayWriter, and SharedArrayTest for this program. Rename the SharedArrayTest class as Program 7 . Change
Use the following classes, SimpleArray synchronized version ArrayWriter, and
SharedArrayTest for this program. Rename the SharedArrayTest class as
Program Change the array size to Modify the run method to enter only
the integers to for the elements of the array. The contents of the array should look
like this: and so on Add a totalArray attribute to the
SimpleArray class to return the sum of the elements in the array. 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 multiThreadedArray
that uses a Fix Thread Pool the size of the number of CPU cores in the system
and the classes named above to populate the array and find and display the
sum of its elements. Do not display the elements of the array. Make sure your
multithreaded code is thread safe and does not populate the array past the end.
Display the CPU cores of the system after the developers information.
Write a nonstatic method in the Program class named singleThreadedArray
that creates a simple integer array of size populates the array with
the same integers as described for the multithreaded version, and returns the
sum of the elements. Do not display the elements of the array.
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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
