Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save carl-mastrangelo/e83d639e116a15092b9293f7d970501f to your computer and use it in GitHub Desktop.

Select an option

Save carl-mastrangelo/e83d639e116a15092b9293f7d970501f to your computer and use it in GitHub Desktop.
from concurrent.futures import ThreadPoolExecutor
count = 0
with ThreadPoolExecutor(max_workers=3) as executor:
def inc():
global count
for i in range(10_000_000):
count = count + 1
executor.submit(inc)
executor.submit(inc)
executor.submit(inc)
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment