Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- def print_squares():
- for i in range(1, 6):
- print(f"Square of {i}: {i*i}")
- def print_cubes():
- for i in range(1, 6):
- print(f"Cube of {i}: {i*i*i}")
- if __name__ == "__main__":
- thread1 = threading.Thread(target=print_squares)
- thread2 = threading.Thread(target=print_cubes)
- thread1.start()
- thread2.start()
- thread1.join()
- thread2.join()
- print("Both threads have finished.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement