How to create n number of threads

Ian Kelly ian.g.kelly at gmail.com
Tue Jun 28 15:48:37 EDT 2011


On Tue, Jun 28, 2011 at 1:33 PM, hisan <santosh.ssit at gmail.com> wrote:
> How to create n number thread in python. i want iterate over the for loop and create a thread for each iteration .
> sample code
>  for i in range(o,50):
>  i want to create 50 thread here which call the same function. how start and stop each thread after completion

from threading import Thread

threads = [Thread(target=func) for i in range(50)]
for thread in threads:
    thread.start()

for thread in threads:
    thread.join()



More information about the Python-list mailing list