Question: Java: Project 2 Multithreaded Sorting Application on Page P - 2 7 Write a multithreaded sorting program that works as follows: A list of integers
Java: Project Multithreaded Sorting Application on Page P
Write a multithreaded sorting program that works as follows: A list of integers is divided
into two smaller lists of equal size. Two separate threads which we will term sorting
threads sort each sub list using the Selection Sort algorithm. The two sub lists are
then merged by the main thread which merges the two sub lists into a single sorted list.
Because global data are shared across all threads, perhaps the easiest way to set up
the data is to create a global array. Each sorting thread will work on one half of this
array. A second global array of the same size as the unsorted integer array will also be
established. The main thread will then merge the two sub lists into this second array.
Graphically, this program is structured as in the figure below.
This programming project will require passing parameters to each of the sorting threads.
In particular, it will be necessary to identify the starting index from which each thread is
to begin sorting.
The main thread will output the sorted array once the merger is complete.
Give the user the option to enter the integer values to be sorted as spaces andor
commas separated or let the user enter the number of integers to be sorted and the
program generates random numbers between and up to that number.
Name your main class as Programjava. No input, processing or output should
happen in the main method. All work should be delegated to other nonstatic
methods and handle all exceptions where necessary.
Allow the user to run the program as many times as possible until a sentinel value of
zero has been entered for the number of integers to be sorted.
Do not use the break statement or the continue statement, in loops, in the
program. Also, do not use the System.exit method the program. You will not
receive credit for the program if you do
All classes in this project must be public, nonstatic and not nested in other
classes.
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.
The Program must be Thread Safe.
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
