Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please type out the code. (Don't submit no screenshots) thank you Form a multithreaded program that mimics a taxi service (Taxi For You) which has

Please type out the code. (Don't submit no screenshots) thank you

Form a multithreaded program that mimics a taxi service (Taxi For You) which has 5 drivers. Customer information is read in from a text file(CustomerList.txt) attached (Delimiter is "yes" while "No" indicates end of file).

Form

a dispatcher program that reads the Customer file for the day and loads the customers into a queue . The dispatcher should create driver threads to serve these customers from the queue. On duty Driver threads should keep picking up customers from the queue. Use sleep to mimic time taken to drop each customer ( Eg:Thread.sleep((long)(Math.random() * 10000));). Drivers can serve a maximum of 4 customers before going offDuty. Find attached the text file CustomerList and Customer.java. Create Dispatcher.java and Driver.java to mimic the dispatcher and drivers. You can add/modify classes as needed. You may use any concurrency mechanisms discussed in class. Using Blocking queues would be the easiest way to accomplish this eg:LinkedBlockingQueue .Send all your files in a zip folder called taxi. Here are snippets of some sample output to give you an idea. Note each run will give a different output depending on your CPU processing. ******************************************************************************************** 2 is on duty. 3 is on duty. 1 is on duty. 5 is on duty. 4 is on duty. Cust#1 has been picked up by driver #2 proceeding from Yorktown Heights to Madison Square Garden (The customercount is 1) Cust#2 has been picked up by driver #3 proceeding from White Plains to Yankee Stadium (The customercount is 1) Cust#3 has been picked up by driver #1 proceeding from Yonkers to MetLife Stadium (The customercount is 1) Cust#4 has been picked up by driver #5 proceeding from Yorktown Heights to Madison Square Garden (The customercount is 1) Cust#5 has been picked up by driver #4 proceeding from White Plains to Yankee Stadium (The customercount is 1) Cust#5 was dropped off at Yankee Stadium by driver #4 Cust#6 has been picked up by driver #4 proceeding from Yonkers to MetLife Stadium (The customercount is 2) Cust#4 was dropped off at Madison Square Garden by driver #5 Cust#7 has been picked up by driver #5 proceeding from Yorktown Heights to Madison Square Garden (The customercount is 2) Cust#1 was dropped off at Madison Square Garden by driver #2 ............................ ............................. Cust#18 has been picked up by driver #4 proceeding from White Plains to Yankee Stadium (The customercount is 4) Cust#18 was dropped off at Yankee Stadium by driver #4 4 is off duty. 4 customers were picked up today.

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

=+48. Oil prices, again. Return to the oil price data of Exercise

Answered: 1 week ago