Alle Dateien aus dem Pythonkurs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

16 lines
390 B

# Quelle: https://stackoverflow.com/questions/35528093/multithreading-in-python-with-a-threadpool
from multiprocessing import Pool
import sys
if __name__ == '__main__':
job_list = [range(10000000)]*6
print(f'{job_list}')
if 'p' in sys.argv:
p = Pool(2)
print("Parallel map")
print(p.map(sum, job_list))
else:
print("Sequential map")
print(map(sum, job_list))