首页 > 编程语言 > 详细

多线程

时间:2017-01-17 15:17:49      阅读:245      评论:0      收藏:0      [点我收藏+]

#coding=utf-8
from time import ctime,sleep
import threading

def music(func):
    for i in range(2):
        print "I was listen to %s. %s" %(func,ctime())
        sleep(3)

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()
    t.join()
    print "all over %s" %ctime()





多线程

原文:http://www.cnblogs.com/tangbinghaochi/p/6293002.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!