Skip to content

Instantly share code, notes, and snippets.

@Bloofer
Created May 30, 2022 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bloofer/abcceec79080c8e93e5a3e37a4034a8c to your computer and use it in GitHub Desktop.
Save Bloofer/abcceec79080c8e93e5a3e37a4034a8c to your computer and use it in GitHub Desktop.
multi_thread
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