Question: The first program you will write will be called Starter.java. This program should not be in a package. This program will do four tasks: Read

The first program you will write will be called Starter.java. This program should not be in a package. This program will do four tasks:

  1. Read from the user that name of a file containing a list of numbers and the number of threads for the Worker program to create. (The number of threads should be an integer between two and 20.)

  2. Get the local Runtime class object using the getRuntime() method.

  3. Use the local runtime object to start your multithreaded program using one of the exec() methods (the simplest to use is exec(String [] cmdarray), where cmdarray[0] is the command to run and the remaining cmdarray elements are the arguments to the command. For this program, cmdarray[0] will hold "java", the java runtime environment command, cmdarray[1] will hold "Worker", the name of the multithreaded program, cmdarray[2] will hold the number of threads to use and cmdarray[3] will hold the name of the file from which the numbers are read..

  4. Tie the output of Worker program to the Starter program using the Process class method getInputStream() on the Worker process you created in step 2 and read the results that the Work program writes and display them.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!