Created
November 6, 2024 21:35
-
-
Save eduardogpg/f26aa4886a4eab98c8ed5fc9b99d911f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from threading import Thread | |
def prepare_dough(): | |
print("Preparing the dough...") | |
time.sleep(3) | |
print("Dough is ready.") | |
def add_ingredients(): | |
print("Adding ingredients...") | |
time.sleep(2) | |
print("Ingredients are ready.") | |
if __name__ == '__main__': | |
start = time.time() | |
t1 = Thread(target=prepare_dough, name='prepare_dough') | |
t2 = Thread(target=add_ingredients, name='add_ingredients') | |
t1.start() | |
t2.start() | |
t1.join() | |
t2.join() | |
print("Pizza is ready!", time.time() - start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment