Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 4 Using threads. This lab is a warm-up for the next assignment. We will learn to build a multi-threaded application. You will write a

Lab 4 Using threads.

This lab is a warm-up for the next assignment. We will learn to build a multi-threaded application. You will write a function that will simulate a long task. You will call the first method a number of times sequentially and record the time it take to complete. The will call the first method again but in a threaded manner and time the execution and then compare the two times.

Create three functions:

  1. Create a function to the following:
    1. Take a string argument (name).
    2. Create a loop that will run for 100_000 time. In this loop, the program will sleep 0.000_1 seconds.
    3. After the completion of the loop, prints its name and a brief message.
  2. Create a second function to do the following:
    1. Takes a number argument (times to execute the loop).
    2. Store the current time.
    3. Call the function in step 1 the required number of times (sequentially).
    4. Check the elapse time after the above calls complete.
    5. Print the results as well as a brief messag
  3. Create a third function to do the following:
    1. Takes a number argument (times to execute the loop).
    2. Store the current time.
    3. Call the function in step 1 the required number of times (as threads).
    4. Check the elapse time after the above calls complete
    5. Print the results as well as a brief message
  4. Write the statements
    1. to call the function in step 2 ten times
    2. to call the function in step 3 ten times

Code to be done in python. I need to create .py file

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago