Tausif K.

asked • 11/20/20

java program to

(a) Implement three classes: Storage, Counter and Printer. The Storage class should store an integer. The Counter class should create a thread and starts counting from 0 (0, 1, 2, 3…) and stores each value in the Storage class. The Printer Class should create a thread that keeps reading the value in the Storage class and printing it. Write a program that creates an instance of the Storage class and set up a Counter and Printer object to operate on it. Identify that, whether synchronization is required or not in this assignment. If yes, implement it.


(b) Modify the above program  i.e 10 (a) to ensure that each number is printed exactly once, by adding suitable synchronization.  


(c) Write a multithreaded program that will accept 4 strings from the command line and search in a particular file for a given string and display the status of each search on the screen. Note that, all threads are operating on the same file.


(d) Write a Java application that will accept two filenames (text files) as command line arguments and use two threads to read contents from the two text files. Each of the threads should sleep for a random time after displaying filename with each line.


(e) Create thread t1 and t2. Set priority of main thread to 10, t1 to  normal priority +2 and t2 to normal priority -2 d) Write a Java application that will accept two filenames (text files) as command line arguments and use two threads to read and display contents from the two text files.


(f)  Write a stream based program which will accept Roll Number, Name, Age and Address from user. Age and Roll-no should be numeric. Handle with built-in exception. None of the field should be blank. Handle with custom exception. Ask user, whether to write the data in the file. If answer is yes, then data is saved into a file as an object (User can write many records in the file), otherwise terminate the current program. Write another program to display all the records saved into the file

1 Expert Answer

By:

Patrick B. answered • 11/21/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.