Question: This assignment will require you to implement a concurrent program (in Java or any or your prefer language that supports multithreading). Please make sure that

This assignment will require you to implement a concurrent program (in Java or any or your prefer language that supports multithreading). Please make sure that you have the computing environment properly configured for building and testing your program before begin. In this assignment, you are asked to simulate two different types of queuing systems found in newfoundland, namely: queue is Tim Hortons and queue in Dominion. The first queue should be implemented in a class called TimQueue and is modeled after the lineup procedure found in most Tim Hortons in St. Johns. In such a queue, there is only one lineup and multiple server station for serving for the customers on that line. After servicing a customer from a service station, the server comes back to the serving station and serve the next customer on the line. All servers are run in parallel. The second type of queue should be implemented in a class called DominionQueue, which is modeled after the customer checkout queue system in the popular grocery store Dominion in St. Johns. Here we have multiple checkout station in the store and each checkout station has its own queue. When a new customer proceed to checkout, it is the customers choice to select a queue among the available ones. For this assignment you can consider, the customer will always select the queue that has the lowest number of customer waiting. If there are multiple queue with lowest number of customer waiting, the new customer can choose one randomly. For the purposes of this assignment, you may assume that it takes between 120 and 600 seconds to serve any customer (uniform distribution) on both of the above queues, and that new customers arrives between every 40 and 120 seconds (also uniformly distributed). Also, both type of the queues has limited capacity. If a customer arrives and see the capacity of the queue(s) full, he/she waits for a maximum of 20 seconds. If no space become available within that time, he/she leaves without being served. You should implement a simulator that will simulate the customer handling situations for both of the cases mention above, where each of the serving stations and checkout stations are simulated by its threads. The process of arriving customers (joking a queue) will be processed by a separate thread. And your queue should be thread safe as the queue will be accessed by multiple threads to add and remove customers. Your simulation will run on a simulated clock (to reduce the run time) and run each simulation separately, each for N minutes on your simulated clock. Your program should receive the value of N as the command line parameter at the start of the execution. For each type of queue, output the total number of customers that arrived, the total number of customers who were forced to leave without being served, the total number of customers served, and the average amount of time taken to serve each customer. You can also create a customer class for this implementation (and any other classes if you need to) that will keep track of the customer, at the very minimum keeps track of the customers arrival time, and the time needed for it to be served. If it was not served because all queues were at maximum capacity, then this fact should also be recorded. You are expected to submit your source code, along with the programs output for 4 hours (240 minutes or 14400 seconds) of the simulation when there are exactly 2 servers in the case of the TimQueue class and 3 checkout stations (and thus 3 queues) in the case of the DominionQueues class, and when the maximum length of a TimQueue is 6, while the maximum length of a DominionQueue is just 2 (this excludes the customer being served). You should use synchronization mechanisms such as locks, semaphores and monitors to implement your solution. You can create two separate programs to simulate two separate queue, or you can put both in one program and use another command line parameter to execute one of the simulation at a time. You must ensure you add the N as command line parameter so that while testing we can run it for any number of minutes we want.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!