为稍后调用的函数运行计时器(python)

时间:2016-07-28 09:03:41

标签: python

def child_thread(i):
    global lock

    while True:
        try:
            lock.acquire()
                f1()
                f2()
                f3()
        finally :
            lock.release()

thread1 = threading.Thread(target=child_thread, args=(0,))
thread1.start()

这里我需要一个f2函数的定时器,它将被调用。线程应该等待一定的时间。我不想睡​​觉。

1 个答案:

答案 0 :(得分:0)

该功能将在30.0秒后调用

from threading import Timer

def hello():
    print "hello, world"

t = Timer(30.0, hello)
t.start()
相关问题