subject

Multithreading. create a multithreaded program that has 3 threads, each one reading a separate file, and each one writing the values read in those files to one of three arrays based on the values read. all values in the files are integers, and the values read (between 1 and 300, inclusive) to are to be placed in the separate arrays as follows: 1) if the value read is from 1 to 100 it gets placed in the first array; 2) if the value read is from 101 to 200 it gets placed in the second array; and 3) if the value is between 201 and 300 it gets placed in the third array. this exercise requires proper synchronization, and requires three classes: arraywriter, multiarray, and a driver class for the main routine. Each of the three arrays must be implemented as a class, MultiArray (NOT an ArrayList), with the following fields: an int writeIndex (the next position to be filled, initialized to 0), and an array of ints with at least 50 integer elements. The MultiArray class must have an add(int) method that is synchronized (either the method must be synchronized or the array it manages must be synchronized); this method adds a passed integer to the array and increments its writeIndex. The ArrayWriter class must implement the Runnable interface, and its job is to is to read an integer from a file, and add it to the appropriate MultiArray. The ArrayWriter constructor must be passed the file (File) and open it, and also be passed the references to the three MultiArrays in which to place the integers read. The run() method reads integers from the file and places in in the appropriate MultiArray by calling the MultiArray's add(int) method. The main routine must: a. prompt the user for three input file names and instantiate three File objects, each with these file names; b. instantiate three MultiArrays; c. instantiate three ArrayWriter objects (passing the constructor the File reference and 3 references to the MultiArrays); d. call the Executors static method newCachedThreadPool, execute each ArrayWriter, and call the shutdown() method; e. wait 1 minute for the three threads to terminate using: try { boolean tasksEnded = executor. awaitTermination (1, Time Unit. MINUTES); if (tasksEnded) { printArray("Array Low", lowArray); printArray("Array Mid", midArray): printArray("Array High", highArray); } else System. out. println("Timed out waiting"); } catch (Exception e) { System. out. printf("Interrupted while waiting: %s\n", e. getMessage(); } f. and implements the printArray() method (above) that displays the each array neatly formatted. Sample data files: File1.txt: 30 130 235 230 240 40 45 140 50 250 150 155 260 160 60 65 70 170 175 270 280 180 185 80 90 190 290 295 20 15 File2.txt: 166 33 133 233 266 243 43 46 143 53 56 253 153 156 263 163 63 73 76 173 273 283 286 183 83 93 96 193 293 16 File3.txt: 37 139 137 237 247 249 47 147 57 59 257 157 159 267 167 67 69 77 177 179 277 287 187 189 87 97 197 297 299 19 Sample output: Enter the first file to scan File 1.txt Enter the second file to scan File2.txt Enter the third file to scan File3.txt Array writer for File 1.txt starts Array writer for File 3.txt starts Array writer for File2.txt starts Array Low 30 37 33 40 43 47 45 46 57 50 53 59 56 60 67 65 63 69 70 73 77 76 80 90 87 97 83 93 20 96 15 19 16 Array Mid 166 130 139 133 137 147 140 143 150 157 155 153 159 156 160 167 163 170 177 175 179 180 173 185 187 189 190 183 197 193 Array High 235 230 237 266 240 247 243 249 250 257 253 260 267 263 270 277 287 273 283 286 290 295 297 299 293

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:00
The animal classthis class represents a an animal residing at a zoo. it has a weight (in pounds),height (in inches), a name, and a color. the methods in the class include constructors,getters, and a tostring. you will finish the implementation of these methods. referto the code documentation.1.getters: you will need to implement getter methods. these get a value (froma member variable) in the animal class. you will make a getter method toreturn each variable (weight, height, name, color). reference getname if youare having issues.2.tostring: you will need to finish the tostring method. this returns a stringcontaining information about an animal. the output string should be of theformat: ” (name) , a ( color )â’colored animal . ( weight ) pounds , ( height ) inches .\n”the height and weight are formatted to 1 decimal place. recall from lab 1how to format strings neatly using string. see the reference sectionfor more about string.format.
Answers: 2
question
Computers and Technology, 22.06.2019 11:00
When working with a team you should always do the following, except? question 3 options: be dependable and trustworthy be sensitive to others feelings do your fair share critique members of the group
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a.if the manual switch s is on, then the light l is on. b.besides the manual switch, there is a motion detector, m1, which activatesthis light.c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d.the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
question
Computers and Technology, 23.06.2019 15:20
An ou structure in your domain has one ou per department, and all the computer and user accounts are in their respective ous. you have configured several gpos defining computer and user policies and linked the gpos to the domain. a group of managers in the marketing department need different policies that differ from those of the rest of the marketing department users and computers, but you don't want to change the top-level ou structure. which of the following gpo processing features are you most likely to use? a, block inheritance b, gpo enforcement c, wmi filtering d, loopback processing
Answers: 3
You know the right answer?
Multithreading. create a multithreaded program that has 3 threads, each one reading a separate file,...
Questions
Questions on the website: 13722362