多线程

2017-08-31  本文已影响9人  Eric_Zeng

http://www.cnblogs.com/fnng/p/3670789.html

#coding=utf-8

import threading

from time import ctime,sleep

def music(func):

for i in range(2):

print "I was listening to %s. %s" %(func,ctime())

sleep(1)

def move(func):

for i in range(2):

print "I was at the %s! %s" %(func,ctime())

sleep(5)

threads = []

t1 = threading.Thread(target=music,args=(u'爱情买卖',))

threads.append(t1)

t2 = threading.Thread(target=move,args=(u'阿凡达',))

threads.append(t2)

if __name__ == '__main__':

for t in threads:

t.setDaemon(True)

t.start()

上一篇 下一篇

猜你喜欢

热点阅读