Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA 1a Create a thread class that accepts the name of a file and when executed will print out the total number of lines in

JAVA

1a Create a thread class that accepts the name of a file and when executed will print out the total number of lines in the file. For example:

 list_1.txt: 60388 (printed from the secondary thread)

1b. Create a loop in your driver class that takes each file in your "lists" directory and passes the file to an instance of your thread class from 2a. Each of the threads should run simultaneously. calculating the total file count of all files in the "lists" directory. Here is some sample output:

list_2.txt: 4690 from Thread-2 list_10.txt: 22227 from Thread-1 list_9.txt: 32193 from Thread-9 list_3.txt: 41242 from Thread-3 list_5.txt: 21877 from Thread-5 list_8.txt: 67725 from Thread-8 list_7.txt: 64662 from Thread-7 list_1.txt: 60388 from Thread-0 list_4.txt: 81883 from Thread-4 list_6.txt: 82532 from Thread-6 

2. Create a word search thread that accepts a file name and a search value and then prints out whether the search value was found in the input file. If a line in the file matches the search term than it should print out the following:

"honda" found in list_1.txt

Searching for a missing term should have appropriate output as well:

"toyota" not found in list_1.txt

Test your word search thread by prompting the user for a search term. For example, your output might look like the following:

Enter a word to search for: honda "honda" found in word-phrase list_1.txt 

3. Change your solution to #1 by starting several threads, one for each word list file, that each simultaneously search for the given search term. Make sure that your output prints which file a term was found within, for example:

Enter a word to search for: honda "honda" found in list_3.txt "honda" found in list_7.txt "honda" found in list_4.txt "honda" found in list_9.txt "honda" not found in list_8.txt "honda" found in list_1.txt "honda" not found in list_5.txt "honda" found in list_6.txt

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 Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Know how to use reservations systems to inventory demand.

Answered: 1 week ago