Created
May 30, 2022 16:07
-
-
Save Bloofer/abcceec79080c8e93e5a3e37a4034a8c to your computer and use it in GitHub Desktop.
multi_thread
This file contains 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 | |
COUNT = 50000000 | |
def countdown(n): | |
while n>0: | |
n -= 1 | |
t1 = Thread(target=countdown, args=(COUNT//2,)) | |
t2 = Thread(target=countdown, args=(COUNT//2,)) | |
start = time.time() | |
t1.start() | |
t2.start() | |
t1.join() | |
t2.join() | |
end = time.time() | |
print('Time taken in seconds -', end - start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment