0

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?

Mnovdef
  • 157
  • 2
  • 5

1 Answers1

-1
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()
Charlie G
  • 534
  • 5
  • 16