Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to create n number of threads

Reply
Thread Tools

How to create n number of threads

 
 
hisan
Guest
Posts: n/a
 
      06-28-2011
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
 
Reply With Quote
 
 
 
 
Ian Kelly
Guest
Posts: n/a
 
      06-28-2011
On Tue, Jun 28, 2011 at 1:33 PM, hisan <(E-Mail Removed)> wrote:
> How to create n number thread in python. i want iterate over the for loopand 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()
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
TB View, Threads, Threads with unread The Invisible Man Firefox 1 03-20-2006 02:09 AM
OT: Number Nine, Number Nine, Number Nine FrisbeeŽ MCSE 37 09-26-2005 04:06 PM
Standard Threads vs Weightless Threads yoda Python 2 08-01-2005 09:12 PM
threads without threads sindica@gmail.com C Programming 4 08-27-2004 09:25 PM



Advertisments