from multiprocessing import Pool
import time
def thread_fn(n):
print(n)
time.sleep(2) # For a live example
if __name__ == '__main__':
p = Pool(6) # Number of concurrent processes
tasks = list(range(24)) # Args for thread_fn
p.map(thread_fn, tasks) # Start all processes
p.close()
p.join()