Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import time
- start = time.perf_counter()
- def do_something(seconds):
- print(f'Sleeping {seconds} second(s)...')
- time.sleep(seconds)
- threads = []
- if __name__ == '__main__':
- for _ in range(10):
- t = threading.Thread(target=do_something,args=[1.5])
- t.start()
- threads.append(t)
- for thread in threads:
- thread.join()
- finish = time.perf_counter()
- print(f'Took {round(finish-start,2)} seconds.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement