Created
September 12, 2024 08:29
-
-
Save civic/0ce748f9ba3de6fc73cf9d7722285960 to your computer and use it in GitHub Desktop.
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
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