Skip to content

Instantly share code, notes, and snippets.

@sanfx
Created August 10, 2014 06:53
Show Gist options
  • Select an option

  • Save sanfx/cffed1fd0b811180d4ed to your computer and use it in GitHub Desktop.

Select an option

Save sanfx/cffed1fd0b811180d4ed to your computer and use it in GitHub Desktop.
You can write the threaded example as:
import concurrent.futures
import itertools
import random
def generate_random(count):
return [random.random() for _ in range(count)]
if __name__ == "__main__":
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
executor.submit(generate_random, 10000000)
executor.submit(generate_random, 10000000)
# I guess we don't care about the results...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment