Start 10 copies of a function running in parallel : Thread Start « Thread « Python






Start 10 copies of a function running in parallel

Start 10 copies of a function running in parallel
import thread

def counter(myId, count):
    for i in range(count): print '[%s] => %s' % (myId, i)

for i in range(10):
    print thread.start_new(counter, (i, 100))

import time
time.sleep(3) 
print 'Main thread exiting.'  

           
       








Related examples in the same category