Let's say I have a list of strings that will be the parameters of a function.
How do I start n
threads (n being the length of the list of parameters), all executing the same function, each one with a parameter from the list?
Let's say I have a list of strings that will be the parameters of a function.
How do I start n
threads (n being the length of the list of parameters), all executing the same function, each one with a parameter from the list?
import threading
single_params = ['param1', 'param2', 'param3']
threads = []
# f() will be a function that takes a single string parameter
for p in single_params:
threads.append(threading.Thread(target=f, args=(p))
for thread in threads:
thread.start()