python 多线程的调取方式

# -- coding: utf-8 --
import urllib, time, thread





def row():
    for i in range(1,1000):
        print('我说1线程')


def row2():
    for i in range(1, 1000):
        print('我说2线程')
#调去线程的方法
#没参数时, thread.start_new_thread(方法名,())
thread.start_new_thread(row,())
thread.start_new_thread(row,())



def get_content(i):
   
    for ss in range(1,1000):
        print '我是 %d 线程'%i

#有参数时  thread.start_new_thread(方法名,(参数1,参数2,......,)
for i in range(5):
    print 'request movie:', i
    thread.start_new_thread(get_content,(i,))

raw_input('press ENTER to exit...\n')

猜你喜欢

转载自blog.csdn.net/qq_38788128/article/details/80355682