python多线程简单例子

python多线程简单例子


作者:vpoet

mail:[email protected]

 1 import thread

 2 def childthread(threadid):

 3     print "I am child thread",threadid

 4     

 5 

 6 def parentthread():

 7     i=0

 8     while 1:

 9         i+=1

10         thread.start_new_thread(childthread,(i,))

11         if raw_input()=='q':

12             break

13 

14 

15 parentthread()

运行截图:

python多线程简单例子

你可能感兴趣的:(python)