Python 定时器
程序员文章站
2022-05-17 21:25:24
...
import threading
class Person(object):
def __init__(self):
print "init person"
def speak(self):
print "speak"
if __name__ == "__main__":
p = Person()
count = 5
while count:
timer = threading.Timer(5, Person.speak, (p,))
print "begin"
count -= 1
timer.start()
timer.join()
print "end join"
import time
import threading
def hello():
print 'hello'
for i in range(3):
t = threading.Timer(5.0, hello)
t.start()
t.join()
上一篇: 获取日期处理JAVA工具类