Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program to 1. Implement the generic Queue class with the method enqueuer, dequeue, and print. Declare the Node class within the Queue

Write a java program to

1. Implement the generic Queue class with the method enqueuer, dequeue, and print. Declare the Node class within the Queue class. 2. Create the ThreadStatistics class to store the count of strings processed and the average length with the needed getters, setters, and override the toString() method. 3. Implement the RequestProcessor class to extend Thread. After processing a String object, use the ThreadStatistics class to update the average length and count of strings processed. 4. Create the ThreadStatisticsSetup to supply a ThreadStatistics object for each thread. This object should be stored in a Queue object (The Queue class was created in Step 1.) 5. Put the main method in a Driver class and test your program.

Each thread in the RequestProcessor class must use a lock before accessing the collection. The threads must be as concurrent as possible, within reason. Each thread must have its own private area to store the average length and count of strings processed by it. This private area must be supplied by ThreadStatisticsSetup. Moreover, these private areas must be stored in a queue by ThreadStatisticsSetup, so that class can easily print the queue in response to the call ThreadStatisticsSetup.print(). The generic queue can be used both for the collection of strings and the collection of private areas for storing thread statistics.

One possible output is Count 1700 average length 49 Count 2603 average length 49 Count 2212 average length 49 Count 1744 average length 49 Count 1741 average length 50

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_2

Step: 3

blur-text-image_3

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What is Aufbau's rule explain with example?

Answered: 1 week ago