Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions