c style thread creation in python
Posted
by
chandank
on Stack Overflow
See other posts from Stack Overflow
or by chandank
Published on 2012-09-20T21:27:47Z
Indexed on
2012/09/20
21:37 UTC
Read the original article
Hit count: 200
python
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)
© Stack Overflow or respective owner