Python 线程(六):Timer(定时器)

时间:2014-03-05 18:46:51   收藏:0   阅读:553

Timer:  隔一定时间调用一个函数,如果想实现每隔一段时间就调用一个函数的话,就要在Timer调用的函数中,再次设置Timer。Timer是Thread的一个派生类

 

bubuko.com,布布扣
 1 import threading
 2 import time
 3 
 4 def hello(name):
 5     print "hello %s\n" % name
 6 
 7     global timer
 8     timer = threading.Timer(2.0, hello, ["Hawk"])
 9     timer.start()
10 
11 if __name__ == "__main__":
12     timer = threading.Timer(2.0, hello, ["Hawk"])
13     timer.start()
bubuko.com,布布扣

Python 线程(六):Timer(定时器),布布扣,bubuko.com

原文:http://www.cnblogs.com/wang-can/p/3582051.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!