Question: This is Python programming to develop a multithread program. Please follow the step below. 1. You need to develop a multithread program in Python to

This is Python programming to develop a multithread program. Please follow the step below.

1. You need to develop a multithread program in Python to simulate a checkout in supermarket. The process of simulation will last for T1 seconds. You do not need to consider thread safety. 2. An integer sequence t is used to record the remaining waiting time for each customer.

3. One thread which runs every one second is used to simulate the processing of the checkout. (a) Reduce the remaining processing time of the first customer by one. (b) Remove the first customer if his remaining processing time reaches zero. (c) Clean the screen and show the new remaining processing time.

4. Another thread is used to generate one new customer every T2 seconds. (a) The new customer will leave the supermarket if he or she needs to join a queue with more than R customers. (b) The processing time for the new customer is a random integer in [Tmin; Tmax)

5. An example program run is shown as follows.

Checkout: 3 12 45 5 61, after one second, we have:

Checkout: 2 12 45 5 61, after one second, we have:

Checkout: 1 12 45 5 61 22, after one second, we have:

Checkout: 12 45 5 61 22, after one second, we have:

Checkout: 11 45 5 61 22

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!