Skip to content

Instantly share code, notes, and snippets.

@dichharai
Last active November 7, 2022 07:58
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 dichharai/4b431a7e491720b83cd8e38101604ae6 to your computer and use it in GitHub Desktop.
Save dichharai/4b431a7e491720b83cd8e38101604ae6 to your computer and use it in GitHub Desktop.
from threading import Thread
from time import perf_counter
def sum_up_to(start: int, end: int):
total = 0
print('start...')
for i in range(start, end):
total += i
print('end...')
print(f'sum from {start}..{end} is {total}.')
if __name__ == "__main__":
start = perf_counter()
t1 = Thread(target=sum_up_to, args=(1, 10_000))
t1.start()
t1.join()
print(f'Took {perf_counter() - start:.6f} seconds.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment