c style thread creation in python
- by chandank
Hi I am new to python and want to create multiple threads in a loop something like (in C style)
for (;i < 10; i++)
thread[i]= pthread_create(&thread[i],&attr,func)
I am not sure how to do the same in python? Basically I want have that thread[] variable as global will create all thread at once and then will start then in once. I have written a similar python program that does it but I think having it in above style will be better.
def thread_create(thread_number):
command_string = "Thread-" + "%d" %thread_number
thread = myThread(thread_number, command_string)
thread.start()
# Start new Threads
for i in range(5):
thread_create(i)