Skip to content

Instantly share code, notes, and snippets.

@civic
Created September 12, 2024 08:29
Show Gist options
  • Save civic/0ce748f9ba3de6fc73cf9d7722285960 to your computer and use it in GitHub Desktop.
Save civic/0ce748f9ba3de6fc73cf9d7722285960 to your computer and use it in GitHub Desktop.
from concurrent.futures import ThreadPoolExecutor
import time
def func():
n = 0
while n < 300_000_000:
n += 1
if __name__ == "__main__":
pool = ThreadPoolExecutor(max_workers=4)
futures = [pool.submit(func) for _ in range(4)]
for f in futures:
f.result()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment